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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssh22端口和非22端口建立秘钥的使用方法相关的知识,希望对你有一定的参考价值。

ssh链接:

  ssh [email protected]

  ssh -p 22222 [email protected]

输入密码登陆

ssh不用收入密码建立密钥

1、生成秘钥

[[email protected] 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 [email protected]
The key‘s randomart image is:
+--[ RSA 2048]----+
|        o.o      |
|       . = .     |
| E      + +      |
|.    . = *       |
|. . + + S o      |
|.o o +   o       |
|*   .   o        |
|o.     .         |
|                 |
+-----------------+
2、22号端口把秘钥发过去

[[email protected] logs]# ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] 

[email protected]‘s password:

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

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

以上是关于ssh22端口和非22端口建立秘钥的使用方法的主要内容,如果未能解决你的问题,请参考以下文章

linux都有哪些22端口的服务?

centos 7 ssh 为啥连接不上 22端口开了

SSH的端口为啥是22(翻译)

linux系统ssh端口是多少?

SSH 密码与秘钥登录方式

Linux开启TCP 22端口(基于SSH协议)