-   Linux - Networking (
-   -   Copying files with scp - from a network to another network (

githin 05-05-2011 07:25 AM

Copying files with scp - from a network to another network
I have a debian box,, in my lab and my laptop also runs debian (on another DHCP lan home network outside school). I can access my lab's debian computer from outside school only by first ssh-ing to a server setup by the school -, and then, from the server ssh-ing to my lab computer. That works fine and I can view all my files on my lab computer from home.

But, I would like to copy some files from my lab computer to my home computer. With scp, I know how to do that if I could connect directly with my school computer. In the present scenario, I can't figure out how to copy files.

Does anyone know how this can be done?


pingu 05-05-2011 07:51 AM

If both lab & laptop are on a private network, which I believe is the case, there are 2 ways to accomplish this.
1) From laptop, ssh in to schools server, which has a public ip.
Then scp from lab to server, followed by scp from laptop to server.
2) If your laptop is behind a decent router, setup portforwarding on router so port 22 is forwarded to laptop.
Then scp from lab to your routers public ip.

NightHorse 05-05-2011 08:00 AM

Hi githin,

You can copy the files to and then transfer them to the other host.

Or you can ssh to and from there scp user@lab:~/src user@home:~/dst
but to do that you need to setup a pub_key private_key authentication between your host at home and your Debian box. To do that:
1. At home box:
$ ssh-keygen -t dsa
2. At gateway
$ scp user@home:~/.ssh/ ~/
$ scp ~/
3. At
$ cat ~/ >> ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys
$ chmod 755 ~/.ssh

You might need to transfer the signature of both hosts on each other, I am not sure about this step cause I don't have same setup to try. but you got the idea.

If the above steps where successful you can from you lab just do ssh 'scp user@lab:~/src user@home:~/dst'

Again I don't have the setup to try that, so If It's successful with you please let me know. :)

githin 05-05-2011 08:06 AM

Additional problem
FOrgot to add this point - The has limited storage space. Its run by the school. I can try to forward the port on the router.

githin 05-05-2011 09:57 PM

Thanks for all the suggestions. It seems my school has a provision to allow direct ssh to my lab computer from outside the campus. If they do it for me, I can use the simple scp command to copy. If not, I will experiment with these methods.

BTW, I cleared up some space on the access machine and tried copying. That works fine, only that it is a two step process. Thanks once again.

All times are GMT -5. The time now is 10:11 AM.