Roots Discourse

Sequel pro + ssh to vagrant

I wasn’t able to connect with the ssh key path shown in other instructions in the forum (the one in the .vagrant.d folder).

I changed it to this and now it works!

Thanks buretta.

5 Likes

so where exactly did you change what? :slight_smile: @ericgauvin and @buretta

I tried it with and without
config.ssh.insert_key = false

My exception

Used command:  /usr/bin/ssh -v -N -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -   o NumberOfPasswordPrompts=3 -i    /Users/fabianhenzler/Development/_marketplace/.vagrant/machines/default/virtualbox/private_key -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 vagrant@local.matrix42.com -L 54107/127.0.0.1/3306

Bad local forwarding specification ' 54107/127.0.0.1/3306'

also tried with all 127.0.0.1 or local.matrix42.com

You click the blue “key” button in the sequel pro gui. Then navigate to that place on your computer.

Here’s what seems to work all in one place:

Some things to note:

  • The name at the top is just the name of your connection favorite, so name it something that won’t be confusing later (the thing to remember is it’s not part of the connection and it should make sense when you come in later and want to use the favorite)
  • sometimes when you clikd the “SSH” tab in sequel pro, it doesn’t show the whole form, you need to toggle between tabs to make it show the whole form (at least for me)
  • use the database username and password that’s in your wordpress_sites.yml file
  • the database name is also in the wordpress_sites.yml file, but it’s optional. You can select a database in sequel pro with the dropdown menu after you connect if you want
  • the ssh key that worked for me was to click the blue key button and navigate to yoursite.com > .vagrant > machines > default > virtualbox > private_key
  • I had a problem with the ssh connection and I went into .ssh/known_hosts and deleted the row for 127.0.0.1. I used sudo. I used nano, locate the line and use Ctrl + K to delete the line.
8 Likes

Today I upgraded to el capitan. Not sure if it was related, but I was unable to connect with sequel pro. It was driving me nuts. Eventually I noticed there was an update for sequel pro. Am able to connect again.

1 Like

exactly! the problem was sequel pro and it’s SSH implementation

1 Like

I hate to revive this thread but I really need to connect to the database and my Sequel Pro is showing a bit of a different layout than what appears in this thread and others.

I’ve tried the alternative SSH Hosts 192.168.50.5 & example.dev. I’ve tried with and without the ssh password that is encrypted in vault.yml (still the default). I’ve restarted my virtual box a few times. I’ve deleted the 127.0.0.1 entry from known_hosts.

But still getting a Permision Denied (publickey) error!

Does anyone have any suggestions? Thanks!

1 Like

You are not alone, exactly the same thing is happening to me right now

Hopefully someone can throw a little knowledge (I am using Navicat in my case but anyways ‘ssh hostname.dev’ fails with Permision Denied (publickey)

$ ssh vagrant@hostname.dev -v
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to hostname.dev [192.168.50.5] port 22.
debug1: Connection established.
debug1: identity file /Users/eduwass/.ssh/id_rsa type 1
debug1: identity file /Users/eduwass/.ssh/id_rsa-cert type -1
debug1: identity file /Users/eduwass/.ssh/id_dsa type -1
debug1: identity file /Users/eduwass/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA fc:ac:d3:12:68:d1:27:48:c2:86:45:b6:e8:5d:bf:a8
debug1: Host 'hostname.dev' is known and matches the RSA host key.
debug1: Found key in /Users/eduwass/.ssh/known_hosts:12
debug1: ssh_rsa_verify: signature correct
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
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/eduwass/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/eduwass/.ssh/github_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/eduwass/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
1 Like

@rob_gordon and @eduwass I had the same issue recently and temporarily had to manually add an alias to my hosts file to connect. It doesn’t fix the root issue but allows you to connect.

So: 127.0.0.1 example.dev

In addition to:
vagrant-hostmanager-start id 192.168.50.5 example.dev 192.168.50.5 www.example.dev vagrant-hostmanager-end

Just wanted to say that worked for me. Thanks!

I’m having exactly the same problem. Dedicated a couple of hours trying to connect to my project. Then downloaded the example project to start with something without my own modifications. Still no success.
After that I found this thread.

So it seems like there is no solution for this at the moment?

Nobody said there was no solution, this thread has many replies of people who have it working. You have to set up SSH in Sequel Pro or your database app. I use it with PHPStorm all the time.

Did you try all the suggestions in this thread?

1 Like

I got it to work on my Mac. Started over and tried the suggestions again. Got it to work.

But I can’t get it to work on my computer at work. On my mac I use PHPStorm and the ssh key in mysite.dev/.vagrant/machines/default/virtualbox/private_key
On my computer at work I don’t have any private key file in my virtual machine :blush:

What could I’ve been doing wrong?

You may be able to see what private key Vagrant uses for its SSH connection by running

vagrant ssh-config
```

If your work machine is running Windows, I'm reminded of this thread:

[quote="DemaniClassic, post:4, topic:4402"]
I am on a Windows 8.1 machine so 'vagrant ssh' does not work out of the box. But after trying that command, the path to the private key was revealed to me.  

I've been able to log in the VM without an SSH key in the past, but maybe something has been updated that makes SSH with a key mandatory, and the Putty client fails because it does not know the path?

I followed the instructions here, and now it works
http://docs-v1.vagrantup.com/v1/docs/getting-started/ssh.html

--
"An SSH client is generally not distributed with Windows by default. Because of this, if you are on Windows, Vagrant will instead output SSH authentication info which you can use with your favorite SSH client, such as PuTTY.

PuTTY may not recognize the insecure_private_key provided by vagrant as a valid private key. To remedy this, first grab the PuTTYgen app. Then use PuTTYgen and import the insecure_private_key (found in the .vagrant.d dir in your home directory) and save a ppk file from that private key. Use the ppk file instead of the default one when SSHing into your vagrant box."
[/quote]

Thanks for the help! I’ve now managed to connect to my vagrant machine from a Windows host using Git Bash and vagrant ssh, or with Putty using the new generated insecure_private_key.ppk.

But when I try to connect with Git Bash using ssh vagrant@myproject.dev it prompts me for a password. And if I try to connect with PHPStorm it asks for the same thing.

On my Mac I haven’t had this problem. Why does it ask for a password, but most importantly, what is the password? :slightly_smiling:

1 Like

Caveat: I’m not on Windows or PHPStorm

As I understand it, there are two connections involved in enabling a tool like SequelPro to connect to a MySQL database on your VM:

1 - Connect to Vagrant VM
This typically is an SSH connection using the Vagrant insecure private key and wouldn’t involve a password.

HostName 127.0.0.1
  User vagrant
  Port 2222
  IdentityFile "/path/to/.vagrant/machines/default/virtualbox/private_key"

If for some reason you find yourself needing a password, the Vagrant docs mention this:

Vagrant does not actually use or expect any root password. However, having a generally well known root password makes it easier for the general public to modify the machine if needed.

Publicly available base boxes usually use a root password of “vagrant” to keep things easy.

2 - Connect to MySQL
This connection does involve a password
username: the value of db_user
password: the value of db_password
port: 3306


If you’re trying to connect to MySQL and it prompts you for a password, it seems like the info in item 2 above would be relevant.

If you’re foregoing Vagrant’s custom vagrant ssh command and trying a manual ssh connection via the command ssh vagrant@myproject.dev, I think you’ll need some extra information in your ssh config. You can probably copy the output of the command vagrant ssh-config and paste it in your own ssh config file. Particularly important would be the IdentityFile entry to specify the private key. Otherwise, if the ssh connection attempt cannot find a valid private key, it may fall back to prompting for a password. I guess you could try vagrant as the password if you’re unable to avoid this.

2 Likes

Here is what worked for me

7 Likes

That worked for me as well! Thanks!