1.使用ssh-keygen生成私钥和公钥
命令如下:
ssh-keygen -t rsa
1
例子:
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wangxiaosheng/.ssh/id_rsa):
Created directory '/home/wangxiaosheng/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/wangxiaosheng/.ssh/id_rsa.
Your public key has been saved in /home/wangxiaosheng/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:CNcHTPggmTpVVu71TBJJYJpVo0M0027qa2qB33Bn1WY wangxiaosheng@yutao-PowerEdge-R430
The key's randomart image is:
+---[RSA 2048]----+
| +o*%==. |
| =.oO.=oo |
| o..+o=.+ .. |
| o o o.+o=. E |
| . .. So .oo |
| . o o o |
| . * o |
| o + |
| ..o.. |
+----[SHA256]-----+
参数 -t rsa 表示使用rsa算法进行加密,执行后,会在/home/当前用户/.ssh目录下找到id_rsa(私钥)和id_rsa.pub(公钥)
fdipzone@ubuntu:~$ ls -lt ~/.ssh
总用量 12
-rw------- 1 fdipzone fdipzone 1679 2015-08-07 00:28 id_rsa
-rw-r--r-- 1 fdipzone fdipzone 397 2015-08-07 00:28 id_rsa.pub
1
2
3
4
也可以使用 dsa 加密算法进行加密,命令如下:
ssh-keygen -t dsa