> For the complete documentation index, see [llms.txt](https://jncia-workbook.gitbook.io/workbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jncia-workbook.gitbook.io/workbook/junos-basics/1-resetting-the-root-password.md).

# 1) Resetting the Root Password

Telnet to R1 (`telnet 10.200.255.2 5000`). You can do this directly from the containerlab server itself, if desired. Press `[enter]`, and login with the credentials provided under the previous page, *Node Access* (`admin`/`admin@123`).

This lab tests your knowledge of how to reset the root password on a router. For this lab, we are pretending that this is a second-hand router that you have purchased which didn't have the config restored to factory defaults. (Of course, you would not be able to login to this router in the first place, but we are only logging in to reboot it and simulate a physical power cycle).

Reload the router using `request system reboot`. This will simulate booting up the router for the first time.

```
admin@R1> request system reboot         
Reboot the system ? [yes,no] (no) yes 

                                                                               
*** FINAL System shutdown message from admin@R1 ***                          

System going down IMMEDIATELY  
```

Your challenge is to interrupt the boot process and reset the root password. This will allow you to gain access into the router.

### Answer

<details>

<summary>Expand to reveal</summary>

You will see this prompt:

```
Autoboot in 2 seconds... (press Ctrl-C to interrupt)
```

\
Enter `ctrl+C`

\
You will see this menu:

```
Main Menu

1.  Boot [D]irectly from Junos volume
2.  Boot Junos volume in [S]afe mode

3.  [R]eboot

4.  [B]oot menu
5.  [M]ore options






Choice: 
```

\
Enter `5`, or `M`.

\
You will see this menu:

```
Options Menu

1. Recover [J]unos volume
2. Recovery mode - [C]LI

3. Check [F]ile system

4. Enable [V]erbose boot

5. [B]oot prompt

6. [M]ain menu



Choice: 

```

\
Enter `2`, or `C`, for recovery mode.

\
After 1-2 minutes, you will see this prompt:

```
Starting CLI ... 

root> 
```

\
Type `configure`

```
root> configure 
Entering configuration mode

[edit]
root# 

```

\
Set the root password using the command below:

```
set system root-authentication plain-text-password
```

\
This will prompt you for the new password. Enter a new password, then `commit`.

```
root# set system root-authentication plain-text-password 
New password:
Retype new password:


[edit]
root# commit 
commit complete

[edit]
root@R1# 
```

\
Reboot the router back into the normal mode:

```
root@R1# exit 
Exiting configuration mode

root@R1> request system reboot 
Reboot the system ? [yes,no] (no) yes 
```

\
From here, you could login as root and then reset the config (which is the next lab).

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

To reset the root password, you must physically console into the device and power cycle it, in order to boot into recovery mode. For the most part, you can rely on following the prompts. Just ensure to catch the interruption prompt and hit `ctrl + C`**.**

\
Note that older devices require you to interrupt using `[space bar]` and then typing `boot -s`. From there, you can also follow the prompts.

\
Be aware that although Junos allows you to enter the plain-text password, it is never stored in the config in plain-text, or even an insecure hash such as Cisco's level 7. Modern Junos code will use SHA-512 by default. This is a secure, non-reversible hash, similar to Cisco's type 8, 9, or 10. Cisco's type 10 is probably the closest comparison, as that also uses SHA-512. Cisco's type 6 hash is a reversible hash, used for secrets such as VPN and RADIUS keys which need to be sent from the router to a remote system.

<br>

#### What happens if you want to reset the root password but retain the config?

By default, resetting the root password does not alter any other configuration.

\
You may want to reset the root password, but retain the config, if you get locked out of your router. For example, this could happen if you accidentally configured a bad RADIUS secret (without commit-confirm!) and cannot remember the root password. In this case, you want to gain access back into the router, while still retaining the config.

\
Unfortunately, you are going to have to suffer an outage to reset the root password. There is no way to *recover* the root password, you can only *reset* it. And resetting it requires you to boot into recovery mode.

\
However, in recovery mode, you will still have your full config. The recovery mode just allows you into the router without needing to log in. You would need to explicitly reset the config if you wished to do that. (Coming up in the next lab).

</details>

### Further Reading

<https://www.juniper.net/documentation/us/en/software/junos/user-access/topics/topic-map/recovering-root-password.html>

<https://www.youtube.com/watch?v=7xCAJhGJTdc&list=PL2ZMKm7ZEEWI_bcDPEWsI_b-TN-uBGcTv&index=5>

* This video shows the older method
