简体   繁体   English

vagrant:在主机和来宾之间共享ssh文件夹

[英]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" . 为了在我的VM中bundle和连接Github作为我的正常自我,我想config.vm.share_folder "ssh", "/home/vagrant/.ssh", "~/.ssh"

Except this breaks vagrant's public/private key authentication. 除了这打破了流浪者的公钥/私钥认证。

Attempted Solution #1 尝试解决方案#1

I tried to copy my public key to also be authorized_keys . 我试图将我的公钥复制为authorized_keys Same behavior; 相同的行为; I need to enter a password to vagrant ssh . 我需要输入一个密码到vagrant ssh

Attempted Solution #2 尝试解决方案#2

Copy the public key to authorized_keys , but also set config.ssh.private_key_path = "~/.ssh/id_dsa" . 将公钥复制到authorized_keys ,但也设置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. 我想你想要研究的是SSH代理转发。 Vagrant has a configuration option to enable this . Vagrant有一个配置选项来启用它 If you are already running an SSH agent locally this is definitely the way to go. 如果您已在本地运行SSH代理,那么这绝对是您的选择。

In fact, even if you aren't running an SSH agent, I would still suggest looking into it. 事实上,即使您没有运行SSH代理,我仍然建议您进行调查。

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. 另一种但非常脏的解决方案可能是使用vagrant shell配置程序将您的私钥放在〜/ .ssh /中,并在〜/ .ssh / config中设置相关条目。 Something like: 就像是:

Host *
    IdentityFile ~/.ssh/my_non_vagrant_key

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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