adduser anujsubediusermod -aG sudo anujsubedisu - anujsubedimkdir ~/.ssh
touch ~/.ssh/authorized_keysssh-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_keyssudo nano /etc/ssh/sshd_config- Change port
22to2611or any other port you want. - Change PasswordAuthentication
yesto PasswordAuthenticationno - Change usePAM
yesto usePAMno - Change ChallengeResponseAuthentication
yesto 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