I am getting Permission denied (publickey) error when doing ssh by ssh username@ip while ssh working when we are doing vagrant ssh
VagrantFile :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "forwarded_port", guest: 80, host: 8071
config.vm.network "private_network", ip: "192.168.33.71"
end
I am trying ssh [email protected] on terminal
Getting Error : Permission denied (publickey)
config.vm.synced_folder '.' and '/home/vagrant/' caused this problem.
Because the configure makes home directory on the host overwritten and destroy .ssh settings on the host.
I got the same problem a few seconds ago. I checked the .ssh was overwritten by Vagrant GUI.
In the summary, your synced folder overrides the .ssh folder in the virtual machine, so you cannot login with ssh.
The answer is from this issue.
Use the private key in your connection with the vagrant box
ssh -i .vagrant/machines/default/virtualbox/private_key [email protected]
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