How to SSH into Server Without Entering Password?

Share:

How to SSH into Server Without Entering Password?

Enable SSH on Remote Side

sudo vim /etc/ssh/sshd_config

PermitRootLogin no # yes ,only if you want to use root to login
PasswordAuthentication yes

or

sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;

Reset ssh

sudo service sshd restart

Remote

Set passwd for user

sudo passwd ubuntu

Client

  • check ssh: ls -al ~/.ssh.
  • Creating a new SSH key if not yet created
ssh-keygen -t ed25519 -C "your_email@example.com"
or
ssh-keygen 

enter 'return' until the end

  • Adding your SSH key to the ssh-agent
eval "$(ssh-agent -s)"

ssh-add ~/.ssh/id_ed25519 [add your private key]
  • Install pub key to remote and connect

ssh-copy-id -i [PUBLIC SSH KEY FILE] [USERNAME]@[HOST]

ssh-copy-id  ubuntu@[remote-ip]
ssh-copy-id -i  ubuntu@[remote-ip]
ssh-copy-id -i server.pub pragmalin@www.example.com

or manually add pub key to ~/.ssh/authorized_keys

  • test
ssh ubuntu@[remote-ip]

cover

Post a Comment