今天想把服務器的安裝包遠程上傳到另一台服務器上去 執行 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 配置文件的具體作用和用法