Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save epicsagas/4ae067a272f30b0cc197d168fa56b966 to your computer and use it in GitHub Desktop.
Save epicsagas/4ae067a272f30b0cc197d168fa56b966 to your computer and use it in GitHub Desktop.
Step by step: create a pem file to login without password and without copy local keys to remote server. SSH authentication like AWS EC2.
  1. Login with account user (not root)
mkdir pem
cd pem
ssh-keygen -b 2048 -f identity -t rsa
  1. Copy public key contents to authorized_keys
cat identity.pub >> ~/.ssh/authorized_keys
  1. Disable Password Authentication
sudo nano /etc/ssh/sshd_config

Change to no to disable tunnelled clear text passwords

PasswordAuthentication no

  1. Restart SSH
sudo service ssh restart
  1. Download your private key to client side
cat ~/.ssh/pem/identity
  1. Set permission for pem on your local
sudo chmod 600 identity.pem
  1. Test login
ssh -i identity.pem user@vps-ip

Credits: https://medium.com/@nhancv/tech-setup-ssh-login-with-pem-file-without-password-on-ubuntu-linux-server-b97dda5a8b8c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment