ssh-keygen的简单使用

1.输入以下命令:

# ssh-keygen -t rsa

2.输入命令ls会看见两个文件公钥私钥

# ls

id_rsa.pub & id_rsa.pub

3.复制id_rsa.pub,并命名为authorized_keys

# cp id_rsa.pub authorized_keys

4.验证是否成功

# ssh localhost

如果成功:

The authenticity of host 'localhost (::1)' can't be established.

RSA key fingerprint is07:07:8e:1c:c0:7e:7f:1f:ca:6a:e6:d3:cb:7f:b7:a1.

 Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'localhost' (RSA) to the list of known hosts.

5.将公钥复制到远程服务器

# scp ~/.ssh/id_rsa.pub 远程用户名@远程服务器ip:~/

6.追加公钥到授权key中

# cat ~/id_rsa.pub >> ~/.ssh/authorized_keys

7.保险起见,删除公钥

# rm ~/id_rsa.pub

你可能感兴趣的:(ssh-keygen的简单使用)