OpenSSH Passwordless Authentication: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Method 1 == # Create a public and private RSA key pair. ## <tt>'''$ ssh-keygen -t rsa'''</tt> ## Follow the prompts to generate and save the RSA key. # Transfer the public...") |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__FORCETOC__ | |||
== Method 1 == | == Method 1 == | ||
# Create a public and private RSA key pair. | # Create a public and private RSA key pair. | ||
# | #: <tt>'''$ ssh-keygen -t rsa'''</tt> | ||
## Follow the prompts to generate and save the RSA key. | ## Follow the prompts to generate and save the RSA key. | ||
# Transfer the public key to the target host. | # Transfer the public key to the target host. | ||
# | #: <tt>'''$ ssh-copy-id <username>@<hostname>'''</tt> | ||
## Follow the prompt to enter your password. | ## Follow the prompt to enter your password. | ||
# Test the passwordless authentication. | # Test the passwordless authentication. | ||
# | #: <tt>'''$ ssh <username>@<hostname>'''</tt> | ||
== Method 2 == | == Method 2 == | ||
# Create a public and private RSA key pair. | # Create a public and private RSA key pair. | ||
# | #: <tt>'''$ ssh-keygen -t rsa'''</tt> | ||
# Create the <tt>'''.ssh'''</tt> directory and set the permissions on the target host. | |||
## Logon to the target host via ssh. | |||
##: <tt>'''$ mkdir .ssh'''</tt> | |||
##: <tt>'''$ chmod 700 .ssh'''</tt> | |||
##: <tt>'''$ touch .ssh/authorized_keys'''</tt> | |||
##: <tt>'''$ chmod 600 .ssh/authorized_keys'''</tt> | |||
# Transfer the public key to the target host. | |||
#: <tt>'''$ cat .ssh/id_rsa.pub | ssh <username>@<hostname> 'cat >> .ssh/authorized_keys''''</tt> | |||
#: Follow the prompt to enter your password. | |||
# Test the passwordless authentication. | # Test the passwordless authentication. | ||
# | #: <tt>'''$ ssh <username>@<hostname>'''</tt> |
Latest revision as of 14:51, 29 January 2022
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>