Rather than create a new SSH key pair on a vagrant box, I would like to re-use the key pair I have on my host machine, using agent forwarding. I've tried setting config.ssh.forward_agent to TRUE in the Vagrantfile, then rebooted the VM, and tried using:
vagrant ssh -- -A
...but I'm still getting prompted for a password when I try to do a git checkout. Any idea what I'm missing?
Simply CMD-SHIFT-P then "Remote-SSH: Connect to Host..." and the ssh . config entry you just added is automatically listed - you simply select it and voila, vscode connects to your remote vagrant vm!
SSH agent forwarding can be used to make deploying to a server simple. It allows you to use your local SSH keys instead of leaving keys (without passphrases!) sitting on your server. If you've already set up an SSH key to interact with GitHub, you're probably familiar with ssh-agent .
It runs in the background on your system, separately from ssh , and it usually starts up the first time you run ssh after a reboot. The SSH agent keeps private keys safe because of what it doesn't do: It doesn't write any key material to disk. It doesn't allow your private keys to be exported.
I'm using vagrant 2 on OS X Mountain Lion.
Vagrant.configure("2") do |config| config.ssh.private_key_path = "~/.ssh/id_rsa" config.ssh.forward_agent = true end
config.ssh.private_key_path
is your local private keyssh-add -L
, if it's not listed add it with ssh-add ~/.ssh/id_rsa
~/.ssh/authorized_keys
on the Vagrant VM. You can do it copy-and-pasting or using a tool like ssh-copy-id Add it to the Vagrantfile
Vagrant::Config.run do |config| # stuff config.ssh.forward_agent = true end
See the docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With