Difference between revisions of "ssh"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(clarifications and a link)
(corrections & a command)
Line 3: Line 3:
 
To enable logging in from a specific remote client with no password (typically so scripts can connect with ssh or [[rsync]]):
 
To enable logging in from a specific remote client with no password (typically so scripts can connect with ssh or [[rsync]]):
 
* Generate a public/private key pair on the client using [[ssh-keygen]]
 
* Generate a public/private key pair on the client using [[ssh-keygen]]
* Copy the public key file (~/.ssh/id_rsa.pub) from the client to ~/.ssh/authorized_keys
+
* Add the public key file (~/.ssh/id_rsa.pub) from the client to ~/.ssh/authorized_keys on the host.
 
** If the latter file doesn't already exist, then it can just be a direct copy of id_rsa.pub.
 
** If the latter file doesn't already exist, then it can just be a direct copy of id_rsa.pub.
 
** If the latter file ''does'' already exist, then id_rsa.pub can just be appended to authorized_keys.
 
** If the latter file ''does'' already exist, then id_rsa.pub can just be appended to authorized_keys.
 +
** The following command should work for either case:
 +
*** <bash>cat .ssh/id_rsa.pub | ssh user@host 'cat >> .ssh/authorized_keys'</bash>
 
* It may be necessary to manually log on once to the client from the host (using the same usernames as above) in order to add the client to the host's known_hosts file; I'm not sure about this part. Need to test.
 
* It may be necessary to manually log on once to the client from the host (using the same usernames as above) in order to add the client to the host's known_hosts file; I'm not sure about this part. Need to test.
 
* Manually log on from the client to the host to make sure that the host is added to the client's known_hosts file, otherwise the verification prompt may interrupt any processes trying to log on automatically.
 
* Manually log on from the client to the host to make sure that the host is added to the client's known_hosts file, otherwise the verification prompt may interrupt any processes trying to log on automatically.

Revision as of 14:40, 23 September 2014

This page is a seed article. You can help HTYP water it: make a request to expand a given page and/or donate to help give us more writing-hours!

Notes

To enable logging in from a specific remote client with no password (typically so scripts can connect with ssh or rsync):

  • Generate a public/private key pair on the client using ssh-keygen
  • Add the public key file (~/.ssh/id_rsa.pub) from the client to ~/.ssh/authorized_keys on the host.
    • If the latter file doesn't already exist, then it can just be a direct copy of id_rsa.pub.
    • If the latter file does already exist, then id_rsa.pub can just be appended to authorized_keys.
    • The following command should work for either case:
      • <bash>cat .ssh/id_rsa.pub | ssh user@host 'cat >> .ssh/authorized_keys'</bash>
  • It may be necessary to manually log on once to the client from the host (using the same usernames as above) in order to add the client to the host's known_hosts file; I'm not sure about this part. Need to test.
  • Manually log on from the client to the host to make sure that the host is added to the client's known_hosts file, otherwise the verification prompt may interrupt any processes trying to log on automatically.
  • If you disable logins now (e.g. via Webmin's "No login allowed" option), you will still be able to log in from a client with an authorized key.

Specific commands for doing this may be found here.