This is a simple guide only for Linux beginners, showing the steps to use only key file to login Linux server and disable password login.
- Assume that you are now logged as
usermod -aG sudo ariel
- Modify the following:
Note: If you have any
/etc/ssh/sshd_config.d/, which has any content of
PasswordAuthentication yes, you can either change the value to
noor simply delete the conf file(s).
- Generate key file (for the prompts just hit enter)
su - ariel
ssh-keygen -t rsa
- Copy publickey
cat id_rsa.pub >> authorized_keys
- Save the privatekey to local
Copy the content and paste it to
your_key_name.pem in your local computer
- Restart sshd of your server
systemctl restart sshd
- On your local, change permission
chmod 400 /your/key/path/your_key_name.pem
- Login with key file
ssh -i /your/key/path/your_key_name.pem ariel@your-server-ip
Copyright statement: Unless otherwise stated, all articles on this blog adopt the CC BY-NC-SA 4.0 license agreement. For non-commercial reprints and citations, please indicate the author: Henry, and original article URL. For commercial reprints, please contact the author for authorization.