In general, for server security, we restrict root user login, limit password login, and enable key login.
Creating a Common User
## Create a common user
$ adduser ubuntu
$ apt-get install sudo
Add user to sudo group
$ usermod -a -G sudo ubuntu
Copy the code
Example Add a public key for a common user
$ su ubuntu
$ mkdir -p ~/.ssh
$ cd ~/.ssh
## Add public key
$ touch authorized_keys
$ cat 'Your public key string' >> authorized_keys
$ chmod 600 authorized_keys
$ chmod 700 ~/.ssh
Copy the code
Set SSH and enable login with a key
$ vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
## Disable root login
PermitRootLogin no
## Disable password logins
PasswordAuthentication no
$ service sshd restart
Copy the code
If this blog has been helpful to you, please remember to leave a comment + like + bookmark.
I am Chen, on the road of technology we forge ahead together!