You need to use the ssh-copy-id script that uses ssh to log into a remote machine using a login password. The syntax is as follows:
ssh-copy-id -i ~/.ssh/id_rsa.pub firstname.lastname@example.org
ssh-copy-id -i ~/.ssh/id_dsa.pub email@example.com
OR use specific port on remote host such as tcp port # 4242:
ssh-copy-id -i /path/key/file.pub "firstname.lastname@example.org -p 4242"
Install ssh-copy-id on a OS X Unix systems
Type the following command:
brew install ssh-copy-id
Step # 1: Create the Keys
Type the following ssh-keygen command to generates, manages and converts authentication keys for your workstation / laptop:
Make sure you protect keys with the passphrase.
Step # 2: Install the public key
Install key in a remote server called www-03.nixcraft.in, enter:
ssh-copy-id -i ~/.ssh/id_rsa.pub email@example.com
Note: If ssh-copy-id command not found on your system, try the following commands to append/install the public key on remote host:
ssh firstname.lastname@example.org "umask 077; mkdir .ssh"
cat $HOME/.ssh/id_rsa.pub | ssh email@example.com "cat >> .ssh/authorized_keys"
Step #3: Use keychain for password less login
OpenSSH offers RSA and DSA authentication to remote systems without supplying a password. keychain is a special bash script designed to make key-based authentication incredibly convenient and flexible (see how to install keychain script on unix). Add following lines to your ~/.bash_profile or shell login file:
/usr/bin/keychain $HOME/.ssh/id_rsa source $HOME/.keychain/$HOSTNAME-sh
Save and close the file.
- keychain: Set Up Secure Passwordless SSH Access For Backup Scripts
- Ubuntu / Debian Linux Server Install Keychain SSH Key Manager For OpenSSH
- Man pages - ssh(1), ssh-agent(1), ssh-add(1), ssh-keygen(1), ssh-copy-id(1)