Musterknabe
Musterknabe

Reputation: 6081

Connection to MySQL via Vagrant not working anymore since El Capitan

I'm using vagrant and I'm using the following config to connect to my database.

enter image description here

SSH Password ist the private_key file in the /.vagrant/machines/default/virtualbox/ folder. This worked without any problems, but since I've updated to El Capitan, I can't connect.

I'm getting those details

Querious was unable to create an SSH connection because the remote host denied permission.

Double-check that the SSH user name and password (or public key, if using key-based authentication) are correct.

OpenSSH_6.9p1, LibreSSL 2.1.7
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 127.0.0.1:2222 as 'vagrant'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:kBFNbCLWp1m4X03xMWxWeCjaQUEa426OsJ5IC/PNisM
debug1: Host '[127.0.0.1]:2222' is known and matches the RSA host key.
debug1: Found key in /Users/tzfrs/.ssh/known_hosts:11
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: permanently_drop_suid: 502
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.

As requestes this is the output of vagrant ssh-config

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

What do I have to do to make it work again?

Upvotes: 0

Views: 1048

Answers (1)

megasnort
megasnort

Reputation: 79

I had the same problem, connecting with PSequel to the Postgresql database in the Vagrant box. Two variations of the same solution:

Vagrant key

  • Execute vagrant ssh-config
  • You'll see a line IdentityFile containing something like /Users/stefbastiaansen/vm/precise-pangolin/.vagrant/machines/default/virtualbox/private_key
  • Connect to ssh -p 2222 -i /Users/yourusername/vm/precise-pangolin/.vagrant/machines/default/virtualbox/private_key [email protected] in a new terminal window
  • You'll get the notice that the authenticity of the host (127.0.0.1:2222) could not be confirmed, and the question if you're sure you wanted to continue connecting. Answer yes.
  • Then open PSequel (Postgres) or Sequel Pro (MySQL) and configure it for SSH tunneling.

    • Host: 127.0.0.1
    • Port: 2222
    • User: vagrant
    • Identity File: /Users/yourusername/vm/precise-pangolin/.vagrant/machines/default/virtualbox/private_key
  • Connect.

Your own key

  • Copy your public key to the clipboard: pbcopy < ~/id_rsa.pub
  • ssh vagrant
  • Add your public key to ~/.ssh/authorized_keys on the vagrant box
  • Open up a new terminal window
  • ssh -p 2222 [email protected]
  • You'll get the notice that the authenticity of the host (127.0.0.1:2222) could not be confirmed, and the question if you're sure you wanted to continue connecting. Answer yes.
  • Then open PSequel (Postgres) or Sequel Pro (MySQL) and configure it for SSH tunneling.

    • Host: 127.0.0.1
    • Port: 2222
    • User: vagrant
    • Identity File: ~/.ssh/id_rsa
  • Connect.

It's the confirmation step that needs to happen before you can connect via ssh.

Upvotes: 1

Related Questions