简体   繁体   中英

vagrant: Share ssh folder between host and guest

In order to bundle and connect to Github as my normal self within my VM, I'd like to config.vm.share_folder "ssh", "/home/vagrant/.ssh", "~/.ssh" .

Except this breaks vagrant's public/private key authentication.

Attempted Solution #1

I tried to copy my public key to also be authorized_keys . Same behavior; I need to enter a password to vagrant ssh .

Attempted Solution #2

Copy the public key to authorized_keys , but also set config.ssh.private_key_path = "~/.ssh/id_dsa" . This just screwed everything up, though.

I think what you want to look into is SSH agent forwarding. Vagrant has a configuration option to enable this . If you are already running an SSH agent locally this is definitely the way to go.

In fact, even if you aren't running an SSH agent, I would still suggest looking into it.

An alternate, but horribly dirty, solution might be to use a vagrant shell provisioner to place your private key in ~/.ssh/ and set the relevant entries in ~/.ssh/config. Something like:

Host *
    IdentityFile ~/.ssh/my_non_vagrant_key

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM