生成ssh-keygen
>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa):
~/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is:
03:5f:cd:46:00:53:85:f4:1d:b7:b7:5f:cd:56:43:5b cbs@localhost
The key's randomart image is:
+--[ RSA 2048]----+
| o+++o ..E|
| ..= ..o+|
| . . = .+o|
| o . . .*|
| S .=|
| . .o|
| .|
| |
| |
+-----------------+
生成了公钥~/.ssh/id_rsa.pub 私钥~/.ssh/id_rsa
输入命令
ssh user@host "cat >>~/.ssh/authorized_keys" < ~/.ssh/id_rsa.pub
将公钥传递到远程主机,完成