Sunday, January 20, 2008

HowTo: Install Identity.pub Into Remote Machines

Installing identity.pub from your local machine into a remote machine can be done in a fewer keystrokes using ssh-copy-id. This ssh-copy-id linux command has been used as one of the few linux commands here but it's usage has never been emphasized and explained.

This quick entry covers on how to facilitate identity.pub remote transfers and installationbetween machines using ssh-copy-id.

What is ssh-copy-id?


ssh-copy-id is a script that uses ssh to log into a remote machine (presumably using a login password, so password authentication should be enabled, unless you’ve done some clever use of multiple identities)

ssh-copy-id also changes the permissions of the remote user’s home, ~/.ssh, and ~/.ssh/authorized_keys to remove group writability (which would otherwise prevent you from logging in, if the remote sshd has StrictModes set in its configuration).


Remote Installation of Identity.pub File
How to transfer your identity.pub into a remote machine's authorized_keys?

cd back to your home ssh folder
# cd ~/.ssh

Assuming we need to transfer id_rsa.pub to a remote host, simply
# ssh-copy-id -i id_rsa.pub remote-user@remote-host

The above line would transfer id_rsa.pub identity public file into the remote host. The contents of id_rsa.pub would then be added or appended to authorized_keys file from remote machine. If authorized_keys file does not exist, it will automatically be created. This authorized_keys file is located under remote host default home location inside the hidden .ssh folder.

Legend:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remote-user required; an existing and active user account from remote machine
remote-host required; remote machine/host, could be a valid host name or IP address
id_rsa.pub required; your public identity RSA file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can do this over and over again with all your linux box, servers and workstations.

The above process can also be done manually without using ssh-copy-id script. The only difference is that transfer of id_rsa.pub contents into authorized_keys file would be manually added by simply editing or creating the authorized_keys file.

Enjoy.
More Articles:
HowTo: Passwordless SSH
HowTo: Passphraseless and Passwordless SSH

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy