如何使用带有“vagrant ssh"的 ssh 代理转发? [英] How to use ssh agent forwarding with "vagrant ssh"?

查看:33
本文介绍了如何使用带有“vagrant ssh"的 ssh 代理转发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想在 vagrant box 上创建一个新的 SSH 密钥对,而是想重新使用我在主机上的密钥对,使用 代理转发.我试过在 Vagrantfile 中将 config.ssh.forward_agent 设置为 TRUE,然后重新启动虚拟机,并尝试使用:

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

...但是当我尝试执行 git checkout 时仍然提示我输入密码.知道我错过了什么吗?

...but I'm still getting prompted for a password when I try to do a git checkout. Any idea what I'm missing?

推荐答案

我在 OS X Mountain Lion 上使用 vagrant 2.

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

  1. config.ssh.private_key_path 是你的本地私钥
  2. 您的私钥必须可供本地 ssh 代理使用.您可以使用 ssh-add -L 检查,如果未列出,请使用 ssh-add ~/.ssh/id_rsa
  3. 添加
  4. 不要忘记将您的公钥添加到 Vagrant VM 上的 ~/.ssh/authorized_keys.您可以通过复制粘贴或使用诸如 ssh-copy-id 之类的工具来完成
  1. config.ssh.private_key_path is your local private key
  2. Your private key must be available to the local ssh-agent. You can check with ssh-add -L, if it's not listed add it with ssh-add ~/.ssh/id_rsa
  3. Don't forget to add you public key to ~/.ssh/authorized_keys on the Vagrant VM. You can do it copy-and-pasting or using a tool like ssh-copy-id

这篇关于如何使用带有“vagrant ssh"的 ssh 代理转发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆