使用ssh-keygen生成私钥和公钥

                       

1.使用ssh-keygen生成私钥和公钥

命令如下:

ssh-keygen -t rsa
  
  
  • 1

例子:

fdipzone@ubuntu:~$ ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/fdipzone/.ssh/id_rsa): 这里输入要生成的文件名Enter passphrase (empty for no passphrase):                       这里输入密码 Enter same passphrase again:                                      这里重复输入密码Your identification has been saved in /home/fdipzone/.ssh/id_rsa.Your public key has been saved in /home/fdipzone/.ssh/id_rsa.pub.The key fingerprint is:f2:76:c3:6b:26:10:14:fc:43:e0:0c:4d:51:c9:a2:b0 fdipzone@ubuntuThe key's randomart image is:+--[ RSA 2048]----+|    .+=*..       ||  .  += +        ||   o oo+         ||  E . . o        ||      ..S.       ||      .o .       ||       .o +      ||       ...oo     ||         +.      |+-----------------+
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

参数 -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
  
  
  • 1


2.设定客户端连接使用的ssh私钥和公钥

vim /etc/ssh/ssh_config
  
  
  • 1

找到

#   IdentityFile ~/.ssh/identity#   IdentityFile ~/.ssh/id_rsa#   IdentityFile ~/.ssh/id_dsa
  
  
  • 1
  • 2
  • 3

把前面#去掉,然后在 IdentityFile 后填写你用来执行ssh时所用的密钥

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值