在安装zsh来装饰终端之前,它工作正常。其实我不确定这是否会引起问题。
我收到一条错误消息: ssh_exchange_identification:连接被远程主机关闭
➜ ssh test_ssh
ssh_exchange_identification: Connection closed by remote host
➜ ssh -v test_ssh
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/mike/.ssh/config
debug1: /Users/mike/.ssh/config line 34: Applying options for test_ssh
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: /etc/ssh/ssh_config line 52: Applying options for *
debug1: Connecting to 15.164.49.113 port 7779.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/mike/.ssh/key/admin.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/mike/.ssh/key/admin.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request
答案 0 :(得分:0)
在我自己的情况下,当我尝试从MacBook终端直接登录到VPS时,我能够从ssh登录并收到此错误
我如何解决此错误 ssh_exchange_identification:连接被远程主机关闭
(在VPS上创建新用户时总是会发生这种情况。由于只有root用户的ssh配置,而没有新用户,因此会出现此错误)
在Macbook终端上 类型 $ cd〜/ .ssh
现在
~/.ssh create a config file with the following content:
$ nano配置
并复制此
Host *
ForwardAgent no
ForwardX11 no
ForwardX11Trusted yes
User shapeshed
Port 22
Protocol 2
保存并退出
类型
$ ls
结果
authorized_keys id_rsa id_rsa1.pub 配置id_rsa.pub已知主机
$ cat id_rsa.pub
(以在macOS终端上查看您的公钥)
复制您的macOS终端公钥和控制X退出(如果您还使用nano文本编辑器)
现在在您的VPS(远程服务器)上 确保您以创建的新用户身份登录
user @ ......不是root
$ cd ~/.ssh
$ ls
请注意,您刚刚
authorized_keysknown_hosts作为您的结果...没有公共密钥供VPS识别从您的计算机登录 现在,让我们在VPS上创建新的id_rsa.pub
$ nano id_rsa.pub
粘贴复制并保存并退出的mac os id_rsa.pub。
类型
$ ssh -vvv user@**.**.**.**
用您的IP替换**,然后从终端登录VPS,无需输入密码。