OpenSSH Passwordless Authentication
Jump to navigation
Jump to search
Method 1
- Create a public and private RSA key pair.
- $ ssh-keygen -t rsa
- Follow the prompts to generate and save the RSA key.
- Transfer the public key to the target host.
- $ ssh-copy-id <username>@<hostname>
- Follow the prompt to enter your password.
- Test the passwordless authentication.
- $ ssh <username>@<hostname>
Method 2
- Create a public and private RSA key pair.
- $ ssh-keygen -t rsa
- Create the .ssh directory and set the permissions on the target host.
- Logon to the target host via ssh.
- $ mkdir .ssh
- $ chmod 700 .ssh
- $ touch .ssh/authorized_keys
- $ chmod 600 .ssh/authorized_keys
- Logon to the target host via ssh.
- Transfer the public key to the target host.
- $ cat .ssh/id_rsa.pub | ssh <username>@<hostname> 'cat >> .ssh/authorized_keys'
- Follow the prompt to enter your password.
- Test the passwordless authentication.
- $ ssh <username>@<hostname>