使用 ssh 密钥远程登录 linux
一、生成密钥 使用 ssh-keygen 命令生成密钥:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
> ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/ma/.ssh/id_rsa): Created directory '/home/ma/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/ma/.ssh/id_rsa. Your public key has been saved in /home/ma/.ssh/id_rsa.pub. The key fingerprint is: 5b:78:9f:ca:37:c0:80:f3:43:af:0c:64:78:5a:60:df ma@localhost.localdomain The key's randomart image is: +--[ RSA 2048]----+ | | | o | | . + o | | . O E. | | * +S+o | | . . o++. . | | o.o .o | | o. .o | | o. . | +-----------------+ |
生成的密钥默认位于~/.ssh/目录下,有两个文件,id_rsa 是私钥,id_rsa.pub 是公钥:
|
1 2 3 4 5 |
> cd ~/.ssh/ > ll total 8 -rw-------. 1 ma root 1675 Mar 16 19:02 id_rsa -rw-r--r--. 1 ma root 406 Mar 16 19:02 id_rsa.pub |
把公钥内容 ... 阅读更多