3

I work at a university, and we have a remote machine(1) that I ssh into.

To do this from my laptop, I believe that I have to first ssh into the university system and then ssh into the particular machine. This all happens automatically for me because the ssh config file has been set up for me. I just type:

ssh -Y comp_name

and I'm in.

I'm currently trying to ssh FROM a totally unrelated remove machine(2) - nothing to do with the university. To ssh from this into my remote_machine(1), I do two separate ssh's:

1. Into the university (ssh-gateway)
2. Into remote_machine(1)

So far so good.

What I want to do is to transfer a file using scp from remote_machine(2) to remote_machine(1). How do I do this when there are these two steps involved?

I initially tried:

scp ./file.txt username@ip_of_remote_machine(1)

but it says

connection refused

I think this is because I need to go into the university network first.

I know my terminology isn't correct, but hopefully you understand what I mean.

DavidPostill
  • 162,382

1 Answers1

5

First, you do not need to login to remote_machine(1) in two steps ever: the following command

  ssh -t me@universitygateway ssh me@remote_machine(1) 

will do it for you, if you have enabled (as I seem to understand) passwordless login.

As for scp'ing, you can do it as follows:

 scp -o ProxyCommand="ssh me@universitygateway nc remote_machine(1) 22"  remote_machine(1):/path/to/file/to/download .
MariusMatutiae
  • 48,517
  • 12
  • 86
  • 136