SSH连接 提示 ssh_exchange_identification: Connection closed by remote host
今天想把服务器的安装包远程上传到另一台服务器上去 执行 scp命令 结果提示 ssh_exchange_identification: Connection closed by remote host
执行命令 ssh -v root@10.0.0.83得出以下提示
[root@localhost .ssh]# ssh -v root@10.0.0.98
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 10.0.0.51 [10.0.0.51] port 10580.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/jenkins type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/jenkins-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request
经查看 是在.ssh目录下有一个config配置文件,配置文件内容如下
[root@localhost .ssh]# cat /root/.ssh/config
# 如果是以域名访问的则添加如下内容:
# host xxx
# HostName xxx.com
# Port 3333
# 如果以ip访问的,则添加如下内容:
#Host neiwang
#User git
HostName "10.0.0.51"
Port 10580
IdentityFile ~/.ssh/jenkins
这个配置文件的作用是可以指定不同的主机的连接的sshx信息
解决方法:
需要修改~/.ssh/config文件
[root@localhost .ssh]# cat /root/.ssh/config
# 如果是以域名访问的则添加如下内容:
# host xxx
# HostName xxx.com
# Port 3333
# 如果以ip访问的,则添加如下内容:
#Host neiwang
#User git
##指定各自的主机名,用于区分
Host git
HostName "10.0.0.51"
Port 10580
IdentityFile ~/.ssh/jenkins
Host oth
HostName 10.0.0.83
Port 22
User root
扩展:
~/.ssh/config 配置文件的具体作用和用法