- Create a new user. In the following example, we will name it bob.
1 | root# useradd -m bob |
- Set the password for the new user.
1 | root# passwd bob |
- In order to add sudo permissions for the new user, add
bob ALL=(ALL) ALL
in/etc/sudoers
or add bob in wheel group withusermod -a -G wheel bob
. - Try to connect SSH with bob user.
1 | ssh bob@localhost |
- Verify you can switch user to root with bob.
1 | bob$ sudo -i |
- Disable root SSH login:
- Edit
# vim /etc/ssh/sshd_config
- and change
#PermitRootLogin yes
intoPermitRootLogin no
.
- Now, we can restart SSH server.
1 | root# systemctl restart sshd.service |