[Enterprise SONiC] Reset Password if forget username and password Follow
Restriction:
- If the arrow key does not work in GRUB menu, please use hot-key instead of arrow key as following.
- "UP": "CTRL+p"
- "DOWN": "CTRL+n"
- "LEFT": "CTRL+b"
- "RIGHT": "CTRL+f"
Broadcom switch
Tested model & firmware version:
- Switch model name:
AS7326-56X
- Edgecore SONiC version:
202006.0
202006.4
202012.2
202111.8
Procedure :
Step 1: Reboot system and press “e” to edit SONiC grub option (e.g SONiC-OS-Edgecore-SONiC_20201123_130028_ec202006_74)
Step 2: Add init=/bin/bash as shown below,
+-----------------------------------------------------------------------------+
|setparams 'SONiC-OS-Edgecore-SONiC_20201123_130028_ec202006_74' |
| |
| search --no-floppy --label --set=root SONiC-OS |
| echo 'Loading SONiC-OS OS kernel ...' |
| insmod gzio |
| if [ x = xxen ]; then insmod xzio; insmod lzopio; fi |
| insmod part_msdos |
| insmod ext2 |
| linux /image-Edgecore-SONiC_20201123_130028_ec202006_74/boot/vmli\ |
|nuz-4.19.0-6-2-amd64 root=UUID=3ec4cab4-38b0-473d-a1ef-0a667f144c1e rw cons\ |
|ole=tty0 console=ttyS0,115200n8 init=/bin/bash quiet net.ifnames=0 biosde\ |
|vname=0 loop=image-Edgecore-SONiC_20201123_130028_ec202006_\ |v
|74/fs.squashfs loopfstype=squashfs ap\ |
|parmor=1 security=apparmor varlog_size=4096 usbcore.autosuspend=-1 pcie_asp\ |
|m=off tg3.short_preamble=1 tg3.bcm5718s_reset=1 |
| echo 'Loading SONiC-OS OS initial ramdisk ...' |
| initrd /image-Edgecore-SONiC_20201123_130028_ec202006_74/boot/init\ |
|rd.img-4.19.0-6-2-amd64 |
+-----------------------------------------------------------------------------+
Minimum Emacs-like screen editing is supported. TAB lists
completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for
a command-line or ESC to discard edits and return to the GRUB menu.
Note: This insertion will be restored after rebooting. Therefore, it's not necessary to edit grub option again.
Step 3: Press Ctrl+x to boot
Loading SONiC-OS OS kernel ...
Loading SONiC-OS OS initial ramdisk ...
[ 2.708038] irq 16: nobody cared (try booting with the "irqpoll" option)
[ 2.714804] handlers:
[ 2.717210] [<ffffffff94c427b0>] serial8250_interrupt
[ 2.722539] Disabling IRQ #16
[ 3.647833] ixgbe 0000:08:00.1: HW Init failed: -17
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
root@(none):/#
Step 4: Now you're able to modify the password by linux command. Username root as example.
root@(none):/# passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Step 5: Reboot the switch by linux command or Power cycle the switch
root@(none):/# reboot -f
Reference: SONiC Github https://github.com/Azure/SONiC/blob/master/doc/SONiC-User-Manual.md#23-how-to-reset-password
Barefoot switch(Wedge100BF-32X/65X)
Tested model & firmware version:
- Switch model name:
Wedge100BF-65X
- Edgecore SONiC version:
202012.1
202012.2
Procedure:
Step1. <BMC> Power cycle the NOS by BMC command.
root@bmc:~# wedge_power.sh reset board type is Mavericks Power reset microserver ... Done root@bmc:~# sol.sh You are in SOL session. Use ctrl-x to quit. -----------------------
Step2. <GRUB> Login to ONIE rescue mode.(Be sure to ONIE rescue mode.)
GNU GRUB version 2.02
┌────────────────────────────────────────────────────────────────────────────┐
│ SONiC-OS-Edgecore-SONiC_20211001_044327_ec202012_bfn_70 │
│ SONiC-OS-Edgecore-SONiC_20211203_013553_ec202012_bfn_121 │
│*ONIE │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└────────────────────────────────────────────────────────────────────────────┘
Use the ▲ and ▼ keys to select which entry is highlighted.
Press enter to boot the selected OS, `e' to edit the commands
GNU GRUB version 2.02
+----------------------------------------------------------------------------+
| ONIE: Install OS |
|*ONIE: Rescue |
| ONIE: Uninstall OS |
| ONIE: Update ONIE |
| ONIE: Embed ONIE |
| DIAG: Accton Diagnostic (accton_wedge100bf) |
| |
| |
| |
| |
| |
| |
+----------------------------------------------------------------------------+
Use the ^ and v keys to select which entry is highlighted.
Press enter to boot the selected OS, `e' to edit the commands
before booting or `c' for a command-line.
Step3. <ONIE> Check the partition where SONIC is installed. In this example, SONIC is installed on the third partition of /dev/sda.
ONIE:/ # parted -l Model: ATA FS128GM280I-AC (scsi) Disk /dev/sda: 128GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 269MB 268MB fat16 EFI System boot, hidden 2 269MB 404MB 134MB ext4 ONIE-BOOT hidden 4 404MB 34.8GB 34.4GB ext4 ACCTON-DIAG hidden 3 69.1GB 103GB 34.4GB ext4 SONiC-OS ONIE:/ #
Step4. Create a provisional folder to mount SONIC partition.
ONIE:/ # mkdir /mnt/sonic_recovery
Step5. Mount the SONIC partition to provisional folder.
ONIE:/ # mount -t ext4 /dev/sda3 /mnt/sonic_recovery
Step6. Go to SONIC partition folder. In this example, we modify the password of admin account in Edgecore-SONiC_20211001_044327_ec202012_bfn_70. Go to the /etc in this version.
ONIE:/mnt/sonic_recovery # ls -l drwxr-xr-x 2 root 0 4096 Dec 15 11:11 disk-img drwxr-xr-x 5 root 0 4096 Dec 15 11:10 grub drwxr-xr-x 8 root 0 4096 Dec 15 16:15 image-Edgecore-SONiC_20211001_044327_ec202012_bfn_70 drwxr-xr-x 7 root 0 4096 Dec 15 11:11 image-Edgecore-SONiC_20211203_013553_ec202012_bfn_121 drwx------ 2 root 0 16384 Dec 15 11:09 lost+found -rw-r--r-- 1 root 0 875 Dec 15 11:10 machine.conf drwxr-xr-x 2 root 0 4096 Feb 10 03:21 migration drwxr-xr-x 4 root 0 4096 Feb 10 03:21 reboot-cause drwxr-xr-x 4 root 0 4096 Dec 15 11:14 warmboot drwxr-xr-x 2 root 0 4096 Dec 15 11:12 ztp ONIE:/mnt/sonic_recovery # cd image-Edgecore-SONiC_20211001_044327_ec202012_bfn_70/rw/etc/ ONIE:/mnt/sonic_recovery/image-Edgecore-SONiC_20211001_044327_ec202012_bfn_70/rw/etc #
Step7. <ONIE> Mark the admin password configuration in "shadow" file. In the example, we remove the admin password configuration by "sed".
ONIE:/mnt/sonic_recovery/image-Edgecore-SONiC_20211001_044327_ec202012_bfn_70/rw/etc # admin_shadow=`awk -F ':' '{$2="";print$0}' shadow | grep admin| sed 's/\ /:/g'` ONIE:/mnt/sonic_recovery/image-Edgecore-SONiC_20211001_044327_ec202012_bfn_70/rw/etc # sed -i "s/admin.*/$admin_shadow/g" shadow
Step8. <ONIE> Reboot device
ONIE:/mnt/sonic_recovery/image-Edgecore-SONiC_20211001_044327_ec202012_bfn_70/rw/etc # reboot
Step9. <SONiC> Login to SONiC by admin account without password and then change the password by "passwd".(refer to [Edgecore SONiC] Username and Password)
sonic login: admin Last login: Thu Feb 10 03:25:18 UTC 2022 on ttyS0 Linux sonic 4.19.0-12-2-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 You are on ____ ___ _ _ _ ____ / ___| / _ \| \ | (_)/ ___| \___ \| | | | \| | | | ___) | |_| | |\ | | |___ |____/ \___/|_| \_|_|\____| -- Software for Open Networking in the Cloud -- Unauthorized access and/or use are prohibited. All access and/or use are subject to monitoring. Help: http://azure.github.io/SONiC/ admin@sonic:~$ sudo passwd admin New password: Retype new password: passwd: password updated successfully
Comments
0 comments
Please sign in to leave a comment.