adduser anujsubedi
usermod -aG sudo anujsubedi
su - anujsubedi
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
ssh-keygen -t rsa -b 4096 -C "[email protected]" # Replace with your email.
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDZ ... anujsubedi@anujsubedi" >> ~/.ssh/authorized_keys # Replace with your public key.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
sudo nano /etc/ssh/sshd_config
- Change port
22
to2611
or any other port you want. - Change PasswordAuthentication
yes
to PasswordAuthenticationno
- Change usePAM
yes
to usePAMno
- Change ChallengeResponseAuthentication
yes
to ChallengeResponseAuthenticationno
ssh -i /path/to/private/key anujsubedi@ip -p 2611 # Replace with your private key and ip.
If you were able to connect to the SSH using the new user, restart the ssh service.
sudo systemctl restart ssh