Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
687 views
in Technique[技术] by (71.8m points)

SSH vagrant Git Permission denied (publickey)

I am using MacOs, Virtualbox, and vagrant. I was trying to run git fetch after ssh-ing to my VM using vagrant ssh. I keep getting the error

Permission denied (publickey).

I have generated ssh key on my local machine. and added the public key to my bitbucket accordingly. So, i suspected there is something wrong with my ssh key, I have looked at so many online solutions and tried many of them but still couldn't resolve the problem.

However, I noticed that I don't have a ~/.ssh/config file inside the vm. could that be the reason? I am very new to SSH so I might be missing a simple silly solution here.

however, in my i have the ~/.ssh/config in my local and it contains the following:

Host 127.0.0.1
AddKeysToAgent yes
ForwardAgent yes

in my vagrantFile I have set the config.ssh.forward_agent = true

And when I run vagrant provision i get the following error:

The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. 
The output for this command should be in the log above. 
Please read the output to determine what went wrong.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A config file is not mandatory. If your SSH URL is [email protected]:<user>/<repo>, it should work.

Try with a config including Host * in case 127.0.0.1 is not the right approach.
See "[Using SSH agent forwarding with Vagrant][1]"

You need to replace your.domain.com with either the domain or the IP address of your Vagrant box.
You can wildcard this with Host *, but this is a really bad idea because it lets every server you SSH to access your keys.

So '*' is just for testing. [1]: https://wildlyinaccurate.com/using-ssh-agent-forwarding-with-vagrant/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...