0

I'm trying to get a file from server1 (localhost) with scp. I am accessing server1 from the gateway server2 (that is the only one accessible from the internet).

I am able to open a ssh connection by using:

ssh -p 2222 -L 8080:localhost:443 myUser@server2

And by googling I found that the scp command should be something like:

scp -P 2222 myUser@127.0.0.1:/sourcePathToFile/file destinationPathToFile

But what I get is

ssh: connect to host 127.0.0.1 port 2222: Connection refused

These are the entries in /etc/hosts

127.0.0.1   localhost
127.0.1.1   server3

What am I doing wrong?

MaPi
  • 213
  • 1
  • 2
  • 7

1 Answers1

1

Assuming that both of these commands are being executed on server1...

If you can log in to server2 using the ssh options you listed above, (connecting to port 2222 on server2), then you should be able to copy the file using

scp -P 2222 /sourcePathToFile/file myUser@server2:/destinationPathToFile

(Unless I'm missing the purpose of forwarding your own local port 8080 to remote port 443, which is the effect of the -L 8080:localhost:443 portion of your ssh command.)

The problem with your scp command was that it was attempting to connect to an ssh server running on server1 on port 2222, when it should be connecting to the ssh server running on server2 on port 2222.