[Enterprise SONiC] Create users in SONiC Follow
- Create a user with the Home Directory.
- Allow the existing users to do the configuration.
- Change the Login Shell for the existing user.
Tested model & firmware version:
- Switch model name:
AS7326-56X
- Edgecore SONiC version
202006.4
202012.0 ~ 202012.4
202111.0 ~ 202111.3
Create a user with the Home Directory.
Step 1: Create a user.
admin@sonic:~$ sudo useradd -m newuser
Note:
-m: this option is to create the user home directory as /home/"username".
Step 2: Setting the password for "newuser".
admin@sonic:~$ sudo passwd newuser
New password:
Retype new password:
passwd: password updated successfully
Result:
admin@sonic:/home$ ls -al
total 20
drwxr-xr-x 1 root root 4096 Oct 14 08:04 .
drwxr-xr-x 1 root root 4096 Oct 12 08:33 ..
drwxr-xr-x 1 admin admin 4096 Oct 13 02:06 admin
drwxr-xr-x 2 newuser newuser 4096 Oct 14 08:04 newuser
Login to the SONiC with "newuser".
sonic login: newuser
Password:
Linux sonic 5.10.0-8-2-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) 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/
Last login: Fri Oct 14 08:22:08 UTC 2022 from 188.188.36.10 on pts/1
$
$ id
uid=1001(newuser) gid=1002(newuser) groups=1002(newuser)
$
$ groups
newuser
Allow the existing users to do the configuration.
Step 1: add the group of the "sudo" and "docker" to the user.
admin@sonic:~$ sudo usermod -G sudo,docker newuser
Note:
-G: this option is for adding the secondary groups and allows add multiple groups.
The group of the "sudo" allows users could do the command with sudo.
The group of the "docker" allows users could login to the FRR to set the routing setting.
Result:
sonic login: newuser
Password:
Linux sonic 5.10.0-8-2-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) 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/
Last login: Tue Oct 25 03:13:23 UTC 2022 from 188.188.36.10 on pts/1
$
$ groups
newuser sudo docker
$
$ sudo config interface ip add Ethernet0 192.168.1.1/24
$ show ip int
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- ------------ -------------- -------------
Ethernet0 192.168.1.1/24 up/down N/A N/A
docker0 240.127.1.1/24 up/down N/A N/A
eth0 188.188.36.204/16 up/up N/A N/A
lo 127.0.0.1/16 up/up N/A N/A
$
$ vtysh
Hello, this is FRRouting (version 8.1).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic#
Change the Login Shell for the existing user.
Step 1: Specify the shell for the existing user.
admin@sonic:~$ sudo usermod -s /bin/bash newuser
Note:
- When create a user without specify the shell, it will use /bin/sh.
- The default "admin" use the /bin/bash.
- "/bin/sh" cannot press tab to check what command can use.
- "bin/sh" cannot see the path from the command line.
/bin/sh
$
$ sudo config interface ip ------> press the tab
$
$
$ cd /etc/sonic
$ pwd
/etc/sonic
/bin/bash
newuser@sonic:~$
newuser@sonic:~$ sudo config interface ip ------> press the tab
ip ipv6
newuser@sonic:~$
newuser@sonic:~$
newuser@sonic:~$ cd /etc/sonic/
newuser@sonic:/etc/sonic$
Comments
0 comments
Please sign in to leave a comment.