I'd like to connect to a vagrant-lxc machine using a ssh-key which is already loaded. To make it a little bit more clear, here's my setup:
- Load ssh-key in Windows via PuTTy
- connect to vagrant host machine via Putty with agent forwarding enabled
After the second step I'd like to bring up the vagrant-lxc machine and ssh into it with the key which was already loaded before. Unfortunately I don't know how to configure vagrant to use this key. It is always using the default key ~/.vagrant.d/insecure_private_key or a specified keyfile from the Vagrantfile.
Is it possible to make vagrant use a loaded key from ssh-agent?
Regards, Christian
If I understood you correctly, your setup looks like this:
Windows box with PuTTY Pageant + your private key -(PuTTY)-> Vagrant host machine -("vagrant ssh")-> LXC box
.In any case, you should let the sshd running on LXC box know about your public keys: put the public key as a separate entry to
$HOME/.ssh/authorized_keys
, where$HOME
is the home directory of the user you log in with ("vagrant"
is default, but use whatever you chose before). Note that this is the public part of the key that you load into PuTTY's Pageant. Note also that PuTTY private key format is not compatible with OpenSSH, so you can't use your PuTTY's private key file with ssh on your Vagrant host box.This will probably be enough.
I cannot test the setup identical to yours, but
"Windows box -(Putty)-> some host (ssh)-> some other host"
combo works with the configuration I mentioned. I assume that"vagrant up"
, which you most likely use, does nothing fancier than calling whateverssh
you have on Vagrant host with the"vagrant@<lcx-box-ip> -P <vagrant-ssh-port>"
, meaning that SSH does the actual key exchange. In this case everything works as I described.If this does not work for some reason, try
"vagrant ssh -p"
, or try connecting from your Windows box via PuTTY directly to the LXC box -- Vagrant has forwarded the SSH port 22 of LXC box to some other port (2222 is default), so connecting via PuTTY to"vagrant@<vagrant-host-ip> -P 2222"
should work as well.Hope this helps.