Quando eu apenas inicio um novo vagrant evn. Não posso ssh diretamente nas caixas até fazer um arquivo vagrant ssh
. Então eu posso ssh diretamente sem problemas.
Nos logs de autenticação, vejo os seguintes erros
Sep 5 14:24:24 node2 sshd[1798]: Connection closed by authenticating user vagrant 10.0.2.2 port 59816 [preauth]
O que provavelmente é alguma configuração que está impedindo que isso funcione.
ssh [email protected] -p 2204
Warning: Permanently added '[127.0.0.1]:2204' (ECDSA) to the list of known hosts.
[email protected]: Permission denied (publickey).
Ssh com depuração
ssh -v [email protected] -p 2204
OpenSSH_8.0p1, OpenSSL 1.1.1c 28 May 2019
debug1: Reading configuration data /home/aaron/.ssh/config
debug1: /home/aaron/.ssh/config line 14: Applying options for 127.0.0.1
debug1: /home/aaron/.ssh/config line 69: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2204.
debug1: Connection established.
debug1: identity file /home/aaron/.ssh/ansible_id_rsa type 0
debug1: identity file /home/aaron/.ssh/ansible_id_rsa-cert type -1
debug1: identity file /home/aaron/.ssh/id_ed25519 type 3
debug1: identity file /home/aaron/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to 127.0.0.1:2204 as 'vagrant'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:dkycbxm6Tr8t45KCUiMbAauvQTtw6+go3sss3nk+nrY
debug1: checking without port identifier
Warning: Permanently added '[127.0.0.1]:2204' (ECDSA) to the list of known hosts.
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/aaron/.ssh/id_ed25519 ED25519 SHA256:RVSwD4SH/PoB+hUiP/wjyEtb+CST8QgPPNl3SO3zuBg explicit agent
debug1: Will attempt key: /home/aaron/.ssh/ansible_id_rsa RSA SHA256:iIXdS4I0sfQFx+Hlb3EtA4iMZDaKVvTDP1Cwj2MUohI explicit agent
debug1: Will attempt key: RSA SHA256:XBZaVosr5ppZecW61cMWfduIETMDKrjAfVle2vaU6Uk agent
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/aaron/.ssh/id_ed25519 ED25519 SHA256:RVSwD4SH/PoB+hUiP/wjyEtb+CST8QgPPNl3SO3zuBg explicit agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: /home/aaron/.ssh/ansible_id_rsa RSA SHA256:iIXdS4I0sfQFx+Hlb3EtA4iMZDaKVvTDP1Cwj2MUohI explicit agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: RSA SHA256:XBZaVosr5ppZecW61cMWfduIETMDKrjAfVle2vaU6Uk agent
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
Vagrant up saída do terminal
vagrant up
Bringing machine 'mgmt' up with 'virtualbox' provider...
Bringing machine 'node1' up with 'virtualbox' provider...
Bringing machine 'node2' up with 'virtualbox' provider...
==> mgmt: Checking if box 'ubuntu/bionic64' version '20190828.0.0' is up to date...
==> mgmt: Clearing any previously set forwarded ports...
==> mgmt: Clearing any previously set network interfaces...
==> mgmt: Preparing network interfaces based on configuration...
mgmt: Adapter 1: nat
mgmt: Adapter 2: hostonly
==> mgmt: Forwarding ports...
mgmt: 22 (guest) => 2202 (host) (adapter 1)
==> mgmt: Running 'pre-boot' VM customizations...
==> mgmt: Booting VM...
==> mgmt: Waiting for machine to boot. This may take a few minutes...
mgmt: SSH address: 127.0.0.1:2202
mgmt: SSH username: vagrant
mgmt: SSH auth method: private key
==> mgmt: Machine booted and ready!
==> mgmt: Checking for guest additions in VM...
mgmt: The guest additions on this VM do not match the installed version of
mgmt: VirtualBox! In most cases this is fine, but in rare cases it can
mgmt: prevent things such as shared folders from working properly. If you see
mgmt: shared folder errors, please make sure the guest additions within the
mgmt: virtual machine match the version of VirtualBox you have installed on
mgmt: your host and reload your VM.
mgmt:
mgmt: Guest Additions Version: 5.2.32
mgmt: VirtualBox Version: 6.0
==> mgmt: Setting hostname...
==> mgmt: Configuring and enabling network interfaces...
==> mgmt: Mounting shared folders...
mgmt: /vagrant => /run/media/aaron/nixdata/Source/ansible-docker/vagrant/swarm
==> mgmt: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> mgmt: flag to force provisioning. Provisioners marked to run always will still run.
==> node1: Checking if box 'ubuntu/bionic64' version '20190828.0.0' is up to date...
==> node1: Clearing any previously set forwarded ports...
==> node1: Clearing any previously set network interfaces...
==> node1: Preparing network interfaces based on configuration...
node1: Adapter 1: nat
node1: Adapter 2: hostonly
==> node1: Forwarding ports...
node1: 22 (guest) => 2203 (host) (adapter 1)
==> node1: Running 'pre-boot' VM customizations...
==> node1: Booting VM...
==> node1: Waiting for machine to boot. This may take a few minutes...
node1: SSH address: 127.0.0.1:2203
node1: SSH username: vagrant
node1: SSH auth method: private key
==> node1: Machine booted and ready!
==> node1: Checking for guest additions in VM...
node1: The guest additions on this VM do not match the installed version of
node1: VirtualBox! In most cases this is fine, but in rare cases it can
node1: prevent things such as shared folders from working properly. If you see
node1: shared folder errors, please make sure the guest additions within the
node1: virtual machine match the version of VirtualBox you have installed on
node1: your host and reload your VM.
node1:
node1: Guest Additions Version: 5.2.32
node1: VirtualBox Version: 6.0
==> node1: Setting hostname...
==> node1: Configuring and enabling network interfaces...
==> node1: Mounting shared folders...
node1: /vagrant => /run/media/aaron/nixdata/Source/ansible-docker/vagrant/swarm
==> node1: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> node1: flag to force provisioning. Provisioners marked to run always will still run.
==> node2: Importing base box 'ubuntu/bionic64'...
==> node2: Matching MAC address for NAT networking...
==> node2: Checking if box 'ubuntu/bionic64' version '20190828.0.0' is up to date...
==> node2: Setting the name of the VM: swarm_node2_1567690918350_55935
==> node2: Clearing any previously set network interfaces...
==> node2: Preparing network interfaces based on configuration...
node2: Adapter 1: nat
node2: Adapter 2: hostonly
==> node2: Forwarding ports...
node2: 22 (guest) => 2204 (host) (adapter 1)
==> node2: Running 'pre-boot' VM customizations...
==> node2: Booting VM...
==> node2: Waiting for machine to boot. This may take a few minutes...
node2: SSH address: 127.0.0.1:2204
node2: SSH username: vagrant
node2: SSH auth method: private key
node2: Warning: Connection reset. Retrying...
node2: Warning: Remote connection disconnect. Retrying...
node2:
node2: Vagrant insecure key detected. Vagrant will automatically replace
node2: this with a newly generated keypair for better security.
node2:
node2: Inserting generated public key within guest...
node2: Removing insecure key from the guest if it's present...
node2: Key inserted! Disconnecting and reconnecting using new SSH key...
==> node2: Machine booted and ready!
==> node2: Checking for guest additions in VM...
node2: The guest additions on this VM do not match the installed version of
node2: VirtualBox! In most cases this is fine, but in rare cases it can
node2: prevent things such as shared folders from working properly. If you see
node2: shared folder errors, please make sure the guest additions within the
node2: virtual machine match the version of VirtualBox you have installed on
node2: your host and reload your VM.
node2:
node2: Guest Additions Version: 5.2.32
node2: VirtualBox Version: 6.0
==> node2: Setting hostname...
==> node2: Configuring and enabling network interfaces...
==> node2: Mounting shared folders...
node2: /vagrant => /run/media/aaron/nixdata/Source/ansible-docker/vagrant/swarm
==> node2: Running provisioner: shell...
node2: Running: inline script
node2: hello from node2 worker
Extraia do log de autenticação /var/log/auth.
Sep 5 13:41:24 node2 systemd-logind[842]: Watching system buttons on /dev/input/event0 (Power Button)
Sep 5 13:41:24 node2 systemd-logind[842]: Watching system buttons on /dev/input/event1 (Sleep Button)
Sep 5 13:41:24 node2 systemd-logind[842]: Watching system buttons on /dev/input/event2 (AT Translated Set 2 keyboard)
Sep 5 13:41:24 node2 systemd-logind[842]: New seat seat0.
Sep 5 13:41:24 node2 sshd[995]: Server listening on 0.0.0.0 port 22.
Sep 5 13:41:24 node2 sshd[995]: Server listening on :: port 22.
Sep 5 13:41:28 node2 sshd[1216]: Accepted publickey for vagrant from 10.0.2.2 port 58726 ssh2: RSA SHA256:1ZgLBFBYfTGKpryguu9GYmEYe7jw5DVr3qAVEpmi+jQ
Sep 5 13:41:28 node2 sshd[1216]: pam_unix(sshd:session): session opened for user vagrant by (uid=0)
Sep 5 13:41:28 node2 systemd-logind[842]: New session 1 of user vagrant.
Sep 5 13:41:28 node2 systemd: pam_unix(systemd-user:session): session opened for user vagrant by (uid=0)
Sep 5 13:41:30 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:30 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:30 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:40 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:40 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:40 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:40 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:40 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:40 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:40 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:40 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:41 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:41 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:41 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:41 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:41 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:42 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:42 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:42 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:41:42 node2 sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 5 13:41:42 node2 sudo: pam_unix(sudo:session): session closed for user root
Sep 5 13:42:43 node2 sshd[1216]: pam_unix(sshd:session): session closed for user vagrant
Sep 5 13:42:43 node2 systemd-logind[842]: Removed session 1.
Sep 5 13:42:43 node2 systemd: pam_unix(systemd-user:session): session closed for user vagrant
Sep 5 14:00:26 node2 sshd[1777]: Connection closed by authenticating user vagrant 10.0.2.2 port 59192 [preauth]
Sep 5 14:08:22 node2 sshd[1780]: Connection closed by authenticating user vagrant 10.0.2.2 port 59362 [preauth]
Sep 5 14:08:40 node2 sshd[1783]: Connection closed by authenticating user vagrant 10.0.2.2 port 59382 [preauth]
Sep 5 14:17:01 node2 CRON[1786]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 5 14:17:01 node2 CRON[1786]: pam_unix(cron:session): session closed for user root
Sep 5 14:20:21 node2 sshd[1795]: Connection closed by authenticating user vagrant 10.0.2.2 port 59798 [preauth]
Sep 5 14:24:24 node2 sshd[1798]: Connection closed by authenticating user vagrant 10.0.2.2 port 59816 [preauth]
Sep 5 14:24:32 node2 sshd[1800]: Accepted publickey for vagrant from 10.0.2.2 port 59820 ssh2: RSA SHA256:1ZgLBFBYfTGKpryguu9GYmEYe7jw5DVr3qAVEpmi+jQ
Sep 5 14:24:32 node2 sshd[1800]: pam_unix(sshd:session): session opened for user vagrant by (uid=0)
Sep 5 14:24:32 node2 systemd-logind[842]: New session 4 of user vagrant.
Sep 5 14:24:32 node2 systemd: pam_unix(systemd-user:session): session opened for user vagrant by (uid=0)
Sep 5 14:24:48 node2 sudo: vagrant : TTY=pts/0 ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash
Sep 5 14:24:48 node2 sudo: pam_unix(sudo:session): session opened for user root by vagrant(uid=0)
Sep 5 14:26:02 node2 sshd[1938]: Postponed publickey for vagrant from 10.0.2.2 port 59824 ssh2 [preauth]
Sep 5 14:26:02 node2 sshd[1938]: Accepted publickey for vagrant from 10.0.2.2 port 59824 ssh2: RSA SHA256:1ZgLBFBYfTGKpryguu9GYmEYe7jw5DVr3qAVEpmi+jQ
Sep 5 14:26:02 node2 sshd[1938]: pam_unix(sshd:session): session opened for user vagrant by (uid=0)
Sep 5 14:26:02 node2 systemd-logind[842]: New session 6 of user vagrant.
Sep 5 14:26:04 node2 sshd[2004]: Received disconnect from 10.0.2.2 port 59824:11: disconnected by user
Sep 5 14:26:04 node2 sshd[2004]: Disconnected from user vagrant 10.0.2.2 port 59824
Sep 5 14:26:04 node2 sshd[1938]: pam_unix(sshd:session): session closed for user vagrant
Depois de fazer algumas alterações no meu arquivo vagrant. Especificamente não usando
box = 'ubuntu/bionic64'
e usando o recomendadobox = "bento/ubuntu-18.04
o projeto bentô
Eles funcionaram como esperado na inicialização, eu poderia ssh.
Este vlogger recomenda usar apenas as imagens do projeto hashicorp ou bento para vagrant. Como eles tendem a funcionar melhor e ter melhor suporte. No meu caso parece ser o caso.