[stordis-toc]
Introduction
If you lose or forget a SONiC password on switch, including the admin password, you can reset it using the console and GRUB menu. This guide provides step-by-step instructions to reset the password and regain access.
Â
Prerequisites
- Access to the switch's serial or USB console port with settings: 115200 baud, 8 data bits, no parity
- Ability to reboot or power on the switch
Â
Step-By-Step Instructions
STEP 1: Connect to the Serial or USB Console and boot the switch
- Use a terminal program with 115200 baud rate, 8 data bits, and no parity.
STEP 2: Wait for the GRUB Menu to Appear
- The GRUB boot menu will display available SONiC OS versions.
STEP 3: Enter GRUB Editor
- Select the SONiC version and press "e" to edit the boot commands.
- Navigate to the line beginning with linux /image- using only left or right arrow keys (or Ctrl + B/F if arrow keys don't work).
STEP 4: Edit Boot Command Line
- Within the highlighted linux /image- line, add init=/bin/bash between the rw and console=tty0 parameters.
- This modification boots the system directly to a root shell.
STEP 5: Boot with Modified Settings
- Press F10 or Ctrl+X to boot using the edited command line.
- The system will start with a root shell prompt.
STEP 6: Reset the Password
- At the prompt, reset the password for your username (e.g., admin) using:
passwd admin- Enter and retype the new UNIX password when prompted.
- The password will update successfully.
STEP 7: Reboot the Switch
- Reboot the switch by executing:
reboot -fOnce the switch reboots normally, log in with your username and the new password.
Â
Note
This method does not require re-editing GRUB after password recovery, as the changes are temporary for this reboot only.
Â
Congratulations!
You have successfully restored the password in SONiC. Now you can access the switch again.
Happy networking!
Â
Useful links:
How can I set up a console connection to Edgecore Open Networking switch?
Where to download the SONiC Virtual Switch (VS) community pre-built image?
Â
For more free resources, visit: https://stordis.com/free-resources/
Â
Comments 0
Comments
Please sign in to leave a comment.