码迷,mamicode.com
首页 > 其他好文 > 详细

ssh22端口和非22端口建立秘钥的使用方法

时间:2017-07-26 17:46:01      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:非22端口   ssh22端口   秘钥   

ssh链接:

  ssh root@192.168.1.250

  ssh -p 22222 root@101.201.43.143

输入密码登陆

ssh不用收入密码建立密钥

1、生成秘钥

[root@localhost logs]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
6b:45:21:25:cf:b2:0d:ac:cd:28:d6:1a:a2:32:82:41 root@localhost.localdomain
The key‘s randomart image is:
+--[ RSA 2048]----+
|        o.o      |
|       . = .     |
| E      + +      |
|.    . = *       |
|. . + + S o      |
|.o o +   o       |
|*   .   o        |
|o.     .         |
|                 |
+-----------------+
2、22号端口把秘钥发过去

[root@localhost logs]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.250 

root@192.168.1.250‘s password:

3、非22号端口把秘钥发过去

[root@localhost logs]# ssh-copy-id -i ~/.ssh/id_rsa.pub ‘-p 22222 root@101.201.43.143‘
root@101.201.43.143‘s password:
下次链接不用收入密码了!

ssh22端口和非22端口建立秘钥的使用方法

标签:非22端口   ssh22端口   秘钥   

原文地址:http://12927979.blog.51cto.com/12917979/1951129

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!