How to SSH into Server Without Entering Password?

Share:
How to SSH into Server Without Entering Password? ## Enable SSH on Remote Side ```sh sudo vim /etc/ssh/sshd_config PermitRootLogin no # yes ,only if you want to use root to login PasswordAuthentication yes ``` or ```sh 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 ```sh sudo service sshd restart ``` ## Remote Set passwd for user ```sh sudo passwd ubuntu ``` ## Client - check ssh: `ls -al ~/.ssh`. - Creating a new SSH key if not yet created ``` ssh-keygen -t ed25519 -C "[email protected]" 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]`` ```sh ssh-copy-id ubuntu@[remote-ip] ssh-copy-id -i ubuntu@[remote-ip] ssh-copy-id -i server.pub [email protected] ``` or manually add pub key to ~/.ssh/authorized_keys - test ``` ssh ubuntu@[remote-ip] ``` cover

No comments