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

SSH

时间:2019-08-02 00:17:48      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:原因   rect   message   eth   padding   检查   war   auth   his   

1. SSH公钥检查

1)SSH 公钥检查是一个重要的安全机制,可以防范中间人劫持等黑客攻击。SSH 连接远程主机时,会检查主机的公钥。如果是第一次该主机,会显示该主机的公钥摘要,提示用户是否信任该主机:

The authenticity of host 192.168.0.110 (192.168.0.110) cant be established.
RSA key fingerprint is a3:ca:ad:95:a1:45:d2:57:3a:e9:e7:75:a8:4c:1f:9f.
Are you sure you want to continue connecting (yes/no)?

当选择接受,就会将该主机的公钥追加到文件 ~/.ssh/known_hosts 中。当再次连接该主机时,就不会再提示该问题了。 如果因为某种原因(服务器系统重装,服务器间IP地址交换,DHCP,虚拟机重建,中间人劫持),该IP地址的公钥改变了,当使用 SSH 连接的时候,会报错:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
e9:0c:36:89:7f:3c:07:71:09:5a:9f:28:8c:44:e9:05.
Please contact your system administrator.
Add correct host key in /home/jiangxin/.ssh/known_hosts to get rid of this message.
Offending key in /home/jiangxin/.ssh/known_hosts:81
RSA host key for 192.168.0.110 has changed and you have requested strict checking.
Host key verification failed.

上面的警告信息说的是:

  • 服务器公钥已经改变,新的公钥的摘要是:e9:0c:36:89:7f:3c:07:71:09:5a:9f:28:8c:44:e9:05.
  • 该服务器原来的公钥记录在文件 ~/.ssh/known_hosts 中第 81 行。

如果确认不是中间人劫持,需要连接到该服务器,怎么办呢?最简单的就是用 vi 打开 ~/.ssh/known_hosts 文件,定位到 81 行,将该行删除。之后就可以使用 ssh 连接了。

2)设置连接新主机时,不进行公钥确认

在首次连接服务器时,会弹出公钥确认的提示。这会导致某些自动化任务,由于初次连接服务器而导致自动化任务中断。或者由于  ~/.ssh/known_hosts 文件内容清空,导致自动化任务中断。 SSH 客户端的 StrictHostKeyChecking 配置指令,可以实现当第一次连接服务器时,自动接受新的公钥。只需要修改 /etc/ssh/ssh_config 文件,包含下列语句:

Host *
 StrictHostKeyChecking no

或者在 ssh 命令行中用 -o 参数

$ ssh  -o StrictHostKeyChecking=no  192.168.0.110

转自:https://blog.csdn.net/aabbcc456aa/article/details/18981279

 

2. 远程服务伪终端

ssh -t -t -i id_rsa user@${remote_ip} "${command}"

 

3. SSH端口转发

 

 

SSH

标签:原因   rect   message   eth   padding   检查   war   auth   his   

原文地址:https://www.cnblogs.com/sylvia-lesson/p/11286123.html

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