How to Reset Password in SONiC?

[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.

go_to_edit.gif

  • 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).

move_to_rw.gif

STEP 4: Edit Boot Command Line

  • Within the highlighted linux /image- line, add init=/bin/bash between the rw and console=tty0 parameters.

edit_boot_command.gif

  • 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.

boot.gif

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.

password_reset.gif

  • The password will update successfully.

STEP 7: Reboot the Switch

  • Reboot the switch by executing:
reboot -f

Once the switch reboots normally, log in with your username and the new password.

login.gif

 

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:

STORDIS support portal FAQ

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

Articles in this section