Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a work computer. I have a home computer. I want to be able to share files between with scp, both our computers are behind routers, which assign a local ip. 198.168.0.*

As well as knowing their outside IP, I would like to know how to browse and share files and log in to one another with ssh, public keys as well please.

Please and thank you.

share|improve this question
    
For security you might wanna look at this: ubuntu.stackexchange.com/questions/2271/… , there also is a mini-guide and a mini-debate about ssh-keys there. –  Source Lab Aug 17 '10 at 7:44

2 Answers 2

up vote 3 down vote accepted

If you want to connect to either computer, you will need to expose the computer through your router's NAT. Set up port forwarding to port 22 on both systems. Ideally, you will want to use keypair authentication and disable password access in /etc/ssh/sshd_config.

Alternatively, if you have SSH access to a third system that can be exposed to the Internet, you can use SSH's built-in forwarding feature (man ssh, look up the -R and -L options and optionally -n) to open a port remotely that forwards back to your system. (For example: Computer A connects to the server with -R 2222:127.0.0.1:22, and computer B connects to the server on port 2222 to gain access to computer A.) There is some overhead involved, however minor.

As a variation on the above port forwarding: You'll likely only be able to open ports on your home computer - this will probably be enough. But if you need to be able to access your work computer from home, you will need to set up your work computer to connect to your home computer with an -R option as above. Then, you will be able to connect (ssh user@localhost:2222) without difficulty.

share|improve this answer
    
"Alternatively" ah SSH, what can't it do? I think the key here is that both computers need to have port 22 forwarded by the router. If you are on windows machines secure.logmein.com/products/hamachi2 hamachi can create your tunnels for you. –  Dmitriy Likhten Aug 16 '10 at 22:00

You can forward port 22 on your home router (See the router manual for a howto on that) to the computer where the SSH-server is running, that way you can connect to your home ip-addres (external IP) from work. If you don't know that IP-address you can look here from your home computer.

The other way around is the same if you have access to the router at your work, but if you don't you might want to take a look at this or you can from your work computer do

ssh -R 8022:127.0.0.1:22 ip.of.home.comp

This will open a connection to your computer and make a TCP-tunnel from you local machine back to your work computer. When you come home you are then able to do:

ssh -o Port=8022 127.0.0.1
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.