SSH login to Linux server
SSH login with provide more security to the server. It provides extra layer of security for the server. It uses public – private key authentication with server which prevents anyone login to the server with out private key. That means login with simple username and password can be depreciated and new two level of security can be added.
Generate public / private key:
We can generate keys by different ways. For better understanding please click here.
Create SSH login for User.
ssh-keygen rsa -f newuser
a) Copy your public key to authorized_keys
i) If you are trying to get SSH login for root then copy it to root .ssh folder.
cat mykey.pub >> /root/.ssh/authorized_keys
ii) If you are setting for particular user then copy it to that user folder
cat mykey.pub >> /<user folder>/.ssh/authorized_keys
b) Restart sshd server:
service sshd restart
Enable SSH only login:
vi /etc/ssh/sshd_config
Set:
PasswordAuthentication no
If we need to set SSH login to particular users only then, set that user name in Allowusers parameter.
AllowUsers root, newUser