• I have 2 PCs, PC1 and PC2, both are in the same local network, A, and both use Unix
    • PC2 does stuff, and when it finishes, it transfers data to PC1 automatically via scp since PC1 & PC2 have fixed IPs within network A
    • I had to bring PC1 home and connect it to my local network, so I know my local IP (which is fixed until I reset the router).
  • The router is from my ISP, so options are limited.


  • I want to still transfer data automatically from PC2 to PC1, and if I do scp, I can put my public address, but that points to the router, and I need it to point towards PC1
    • How do you do this? I guess you need a tunnel, but I don't know how to do that.
  • You either have a ISP that gives you a public IP (IPv6 will do), or you need to pay your ISP to give you a public IP, or you need to pay a cloud hoster to give you a public IP (which you can then tunnel), or you can get a VPN into whatever network PC2 is on (probably you employer's, in which case he needs a public IP).
    – dirkt
    May 21, 2020 at 12:51
  • Provided you don't reboot your [home] modem, you should maintain the same WAN IP if your ISP doesn't assign you a static WAN IP, so the easiest way to accomplish this would be to create a DNAT rule [port forward] on the router, forwarding an arbitrary high WAN-side port >50000 to the local IP of PC1 and the port PC1 uses to accept scp connections. PC2 would then scp to the WAN IP and WAN-side port configured in the DNAT rule, which should then successfully connect to PC1. (The only caveat is if your ISP doesn't assign a static WAN IP, you may want to look into a DDNS subscription.)
    – JW0914
    May 21, 2020 at 13:07
  • I create a virtual nertwork from my router following your comment (I found what you said is also called like that). I put as an example port 55000. Then I also opened this port in the router (just in case). Now I did from PC2: scp -P 55000 TEST.sh MYUSERNAME@MYPUBLICIP:/ but it gets like stuck, as if I would have to add something else to the command... May 21, 2020 at 13:52

1 Answer 1


ngrok can help you set up a tcp tunnel which you can use to connect to your home PC. Here's the link : https://ngrok.com/. It works with linux, windows and MacOS, choose your OS, download and sign up for an account on ngrok. after installing, follow the instructions in : https://ngrok.com/docs#tcp to expose the ssh server on PC1:

./ngrok TCP 22

Forwarding tcp://1.tcp.ngrok.io:55147 -> localhost:22

Then on PC2:

scp your_files [email protected] -p 55147

The free version of the software should be enough for your need.

  • It's a bit slow though, but it works! Thanks! Just in case: User is the user from your PC. When you execute ./ngrok TCP 22 see the Forwarding line and modify both the adress and port for the line scp. May 21, 2020 at 16:04
  • After a long time without using it, I just want to point out that: ./ngrok tcp 22 (tcp is in lower case) and: scp -P 55147 your_files [email protected]: Oct 21, 2020 at 11:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .