ssh-copy-id

Installation

brew install ssh-copy-id

Upload public key

$ ssh-copy-id -i <your_id_name> <username>@<server_ip>

## Enter your password now.
$ ssh -i <your_id_name> <username>@<server_ip>

Example:

$ ssh-copy-id -i id_rsa_bandwagon.pub abc@8.8.8.8

$ ssh -i id_rsa_bandwagon abc@8.8.8.8

If use default id_rsa

$ ssh-copy-id <username>@<server_ip>

$ ssh <username>@<server_ip>

Example - iPhone

Generate new key

➜  ~ ssh-keygen -t rsa -b 4096 -C "iphone5c"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/illnino/.ssh/id_rsa): 5c_id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/illnino/.ssh/5c_id_rsa.
Your public key has been saved in /Users/illnino/.ssh/5c_id_rsa.pub.
The key fingerprint is:
fb:2d:4a:c3:4a:b9:5a:da:6e:77:49:50:ac:c5:71:06 iphone5c
The key's randomart image is:
+--[ RSA 4096]----+
|         oEoo    |
|          =o     |
|         +       |
|        o        |
|        S.       |
|       o ..      |
|      + =. .     |
|     =.+.o+.     |
|    o+=..o...    |
+-----------------+

Upload new key

➜  ~ ssh-copy-id -i ~/.ssh/5c_id_rsa.pub root@192.168.123.224

Login with new key

➜  ~ ssh -i ~/.ssh/5c_id_rsa root@192.168.123.224
iPhone5c:~ root#

Create Shortcut

➜  ~ vim ~/.ssh/config
Host iphone5c
   HostName 192.168.123.224
   User root
   Port 22
   IdentityFile ~/.ssh/5c_id_rsa
Show Comments