SSH two computers behind firewalls through external server
I own two computers at a University. Both of them are behind some sort of firewall etc. which disallows me to directly connect them over the network. They can both SSH public computers, but I can't figure out how to ssh from one to the other. I also run a small website. My question is, can I use the public address of my website to somehow connect my two computers without all the information flowing through my website and eating all my bandwidth? Ideally I'd like to create a ssh tunnel between my two computers.
I've already tried Hamachi, it doesn't play well with macs anymore and I'd开发者_如何学运维 like more control over the connection.
Let's assume you want to ssh from MachineA to MachineB (both at the university) by going through your ServerC (your public server).
You will need to run sshd on the ServerC and on MachineB.
Run the following commands, assuming your sshd is listening on port 22 on MachineB and ServerC :
# Forward incoming connections from ServerC:22000 to MachineB:22
(on MachineB) ssh -R22000:127.0.0.1:22 -N user@ServerC
# Forward incoming connections from 127.0.0.1:22000 to ServerC:22000
(on MachineA) ssh -L22000:127.0.0.1:22000 -N user@ServerC
# Establish the link between MachineA and MachineB
(on MachineA) ssh -p 22000 user@127.0.0.1
This method only needs access to the port 22, and you can easily change this to 80 or 443 if your university proxy is evil.
精彩评论