I'm trying to scp files from my machines desktop into my vagrant box but I seem to keep running into this error.
ssh: connect to host 127.0.0.1 port 22: Connection refused
lost connectionI looked into my vagrant file and found this line:
Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine. config.vm.network "forwarded_port", guest: 80, host: 8080I've tried running these commands and have gotten the following errors respectively:
scp -P 80 nginx.conf xxxxx@127.0.0.1:/etc/nginx/nginx.conf
ssh: connect to host 127.0.0.1 port 80: Connection refused
lost connection
scp -P 8080 nginx.conf xxxxx@127.0.0.1:/etc/nginx/nginx.conf
ssh_exchange_identification: Connection closed by remote host
lost connectionI've tried running these commands but it still doesn't work either.
sudo apt-get install openssh-client
sudo apt-get install openssh-serverAny help would be appreciated.
2 Answers
According to the Vagrant docs, the correct way to SSH into a Vagrant box is:
vagrant sshHave a look at the configuration settings for Vagrant SSH to see how to manage SSH. Also, have a look at to see some ways of copying files to your Vagrant machine.
2The lines you showed us are most likely for http access (with your web browser).
To find what port you have to use with ssh/scp follow the boot process after you typed vagrant up, you will find a line about forwarding a port 22->2200 (or similar).
Then you will have to specify "vagrant" as user to connect with the box. For plain ssh-access the standard vagrant ssh is easier.