I've combed the Internet clean for this one and still can't figure it out. I have a Vagrant VM running using VirtualBox, with the following Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "public_network"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.gui = true
end
end
Vagrant launches successfully, and I can run vagrant ssh
successfully and get into the box. I can view the IP of the Vagrant public network, and I'm successfully hosting two Nginx sites in the box, which I can view from a different computer on the same network by visiting the IP of the Vagrant public network.
My server is a clunky laptop, so I want to ssh directly into the Vagrant box that's running on it (from a different development machine). I specifically want to edit the files on the server remotely using the VS Code remote dev tool. I can't for the life of me figure out why, when I run
ssh vagrant@[IP of Vagrant public network on the server]
it gives me "Permission denied (publickey)." It throws this both when I try to run it on the server itself and from another machine on the network.
Do I need to modify some ssh config file somewhere?
EDIT: I read this article, which recommended adding something like this to the ssh config file on the client machine:
Host 192.168.100.100 <- Vagrant box network IP
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IdentitiesOnly yes
User vagrant
IdentityFile /your/user/directory/.vagrant.d/insecure_private_key
PasswordAuthentication no
this didn't work for me; instead of throwing "Permission denied," it just hangs.
question from:
https://stackoverflow.com/questions/65910262/permission-denied-message-when-attempting-ssh-to-vagrant-public-network-ip-from 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…