Saturday, April 20, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 2097  / 2 Years ago, wed, september 21, 2022, 3:59:07

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 connection


I 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: 8080


I've tried running these commands and have gotten the following errors respectively:



scp -P 80 nginx.conf [email protected]:/etc/nginx/nginx.conf
ssh: connect to host 127.0.0.1 port 80: Connection refused
lost connection

scp -P 8080 nginx.conf [email protected]:/etc/nginx/nginx.conf
ssh_exchange_identification: Connection closed by remote host
lost connection


I've tried running these commands but it still doesn't work either.



sudo apt-get install openssh-client
sudo apt-get install openssh-server


Any help would be appreciated.


More From » 14.04

 Answers
5

According to the Vagrant docs, the correct way to SSH into a Vagrant box is:



vagrant ssh


Have a look at the configuration settings for Vagrant SSH to see how to manage SSH. Also, have a look at https://stackoverflow.com/questions/16704059/easiest-way-to-copy-a-single-file-from-host-to-vagrant-guest to see some ways of copying files to your Vagrant machine.


[#23989] Wednesday, September 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aveerakfas

Total Points: 106
Total Questions: 148
Total Answers: 129

Location: Monaco
Member since Sun, Jan 1, 2023
1 Year ago
;