ssh_exchange_identification—Connection closed by remote host and vagrant ssh is no longer available

Asked 3 months ago, Updated 3 months ago, 5 views

■Environment
centros 7.0

■Error Message
·Vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==>default: Checking if box'chef/centos-7.0' is up to date...
==>default: There was a problem while downloading the metadata for your box
==>default: to check for updates. This is not an error, since it is useful due
==>default: to temporary network problems. This is just a warning. The problem
== > default: encountered was:
==>default:
== > default: The requested URL returned error: 404 Not Found
==>default:
==>default: If you want to check for box updates, verify your network connection
==>default: is valid and try again.
==>default: Clearing any previously set forwarded ports...
==>default: Clearing any previously set network interfaces...
==>default:Preparing network interfaces based on configuration...
    default —Adapter 1:nat
    default:Adapter 2:hostonly
==>default: Forwarding ports...
    default:8000=>12345(adapter1)
    default:22=>2222(adapter1)
==>default: Booting VM...
==>default: Waiting for machine to boot. This may take a new minutes...
    default:SSH address:127.0.0.1:2222
    default:SSH username:vagrant
    default:SSH auth method:private key
    default:Warning:Connection timeout.Retrying...
    default:Warning:Connection timeout.Retrying...
    default:Warning:Connection timeout.Retrying...

·Vagrant ssh time

 ssh_exchange_identification:Connection closed by remote host

■ hosts.allow

ALL: 127.0.0.1
sshd —ALL

known_hosts has been deleted.While I was working on it, this suddenly happened.
Could you tell me the solution?

CentOS 7 is a guest OS launched in virtualBox.

ssh-vvv-p2222-i to /.vagrant.d/insecure_private_key-lvagrant 127.0.0.1
When I ran , I received the following message:
What should I do?

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data/Users/mae/.ssh/config
debug1: Reading configuration data/etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line21: Applying options for *
debug2: ssh_connect:needpriv0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file/Users/mae/.vagrant.d/insecure_private_key type-1
debug1: key_load_public: No such file or directory
debug1: identity file/Users/mae/.vagrant.d/insecure_private_key-cert type-1
debug1: identity file/Users/mae/.ssh/id_rsa type1
debug1: key_load_public: No such file or directory
debug1: identity file/Users/mae/.ssh/id_rsa-cert type-1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
ssh_exchange_identification —Connection closed by remote host

vagrant

2022-09-30 13:54

3 Answers

I compare the log from my environment (ubuntu15.10) to the successful guest OS (CentOS 6.7) ssh, but it seems to be almost the same line from ssh_exchange_identification: Connection closed by remote host.

$vagrantup
...
...
(Check the private key that vagrant uses for ssh access after the guest OS starts.)
$ vagrant ssh-config
Host wwww
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile/dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile/home/cul8er/xxxx/.vagrant/machines/www/virtualbox/private_key
  IdentityOnly yes
  LogLevel FATAL
$ ssh-vvv-p222-lvagrant-i/home/cul8er/xxxx/.vagrant/machines/www/virtualbox/private_key 127.0.0.1
OpenSSH_6.9p1Ubuntu-2, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data/home/cul8er/.ssh/config
debug1: Reading configuration data/etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line19: Applying options for *
debug2: ssh_connect:needpriv0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file/home/cul8er/xxxx/.vagrant/machines/www/virtualbox/private_key type-1
debug1: key_load_public: No such file or directory
debug1: identity file/home/cul8er/xxxx/.vagrant/machines/www/virtualbox/private_key-cert type-1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9p1Ubuntu-2

<The log so far looks almost the same as when the question occurred>

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5 *compat0x0c00000000
debug2: fd3 setting O_NONBLOCK
debug1: Authenticating to 127.0.0.1:2222 as 'vagrant'
...
...
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1:Trying private key: /home/cul8er/xxxx/.vagrant/machines/www/virtualbox/private_key
...
...
debug1: Authentication succeeded (publickey).
Authenticated to 127.0.0.1 ([127.0.0.1]:2222).
...
...

According to some web page descriptions, this error seems to have multiple causes.
Among them, ssh_exchange_identification: Connection closed by remote host page contains a relatively comprehensive description.

  • If the remote server (guest machine side in this question) has connection control on either or both hosts.allow and hosts.deny
  • Server overload: If the server you are trying to log in to has a large number of zombie processes associated with sshd and the connection maximum has been reached
  • If the fingerprint information is corrupted for some reason.~/.ssh/known_hosts may be erased, or the server-side public key file (authorized_keys) may be re-created, or /etc/ssh/*key* may not be restarted.
  • glibc or opensl if your dependency with ssh/sshd breaks down after upgrading

For your information.


2022-09-30 13:54

After creating a guest OS with vagrantup in a Vagrant 1.7.4 environment, we created a box with vagrant package and changed the path of the SSH private key from vagrantup to in a Vagrant 1.7.4 environment.

In order to replace the key pair of the box and guest OS using the unsafe key pair adopted by Vagrant 1.7, the guest OS corresponds to the secret key~/.vagrant.d/insecure_private_key contained in the Vagrant handout.

The solution is to create a public key corresponding to the private key in your environment (this public key is virtually published online, so https://github.com/mitchellh/vagrant/tree/master/keys Do not mask)

$ssh-keygen.exe-y-f to /.vagrant.d/insecure_private_key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==

After generating the public key as the , log in to Linux in the guest OS as the vagrant user and use the public key as the previous one.

$cat<<'EOS'>>~/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==vagrant insecure public key
EOS

In the , register the vagrant user public key authentication SSH login for the guest OS.

After you leave the guest OS, do vagrant half and

$vagranthalt
==>default: Attempting graceful shutdown of VM...
    default:
    default —Vagrant insecure key detected.Vagrant will automatically replace
    default —This with a newly generated keypair for better security.
    default:
    default —Inserting generated public key with guest...
    default —Removing insecure key from the guest ifs present...
    default —Key inserted!Disconnecting and reconnecting using new SSH key...

appears, generating and replacing a new key pair for vagrantssh.

From now on, vagrant up will be successful.


2022-09-30 13:54

I also fell in love with it the other day, but is there a possibility that ssh is not installed in the guest OS??

If you edit the Vagrantfile as follows and vagrant up, the GUI will start, so I would like you to log in with vagrant on the screen and see if the ssh command is installed.If it's not installed, I can't ssh in the first place, so I'll lose my vagrant ssh.

config.vm.provider "virtualbox" do | vb|
#   #Display the VirtualBox GUI when booting the machine
  vb.gui=true
#
#   #Customize the amount of memory on the VM:
#   vb.memory="1024"
end

Ah, it says, "Suddenly like this." If it was done before, I don't think there is a possibility of ↑.


2022-09-30 13:54

If you have any answers or tips


© 2023 OneMinuteCode. All rights reserved.