What situations do I have to use one in detriment to the other? I believe that both serves for the same situations at the most of the case, isn't?

closed as off-topic by user34720, Stephen Kitt, Anthon, mdpc, Ramesh Apr 4 '15 at 18:46

  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    I'm voting to close this question as off-topic because, there is already a question about this subject: superuser.com/questions/436485/vpn-tunnel-vs-ssh-tunnel – user34720 Apr 4 '15 at 16:37
  • @nwildner That would make it a duplicate (and "possible duplicates" don't show up if listed on other StackExchange sites). I don't think it's directly off-topic here, but as VPN is not Unix-specific, SuperUser would be a better location for the question. – IQAndreas Apr 4 '15 at 18:43

ssh works at the application layer whereas a VPN works at the transport or network layer.

As a VPN works at the lower layers it can configure routing etc so that your remote computer works as if it were connected to your LAN.

A ssh tunnel can't do this at the application layer therefore the remote user has to configure the tunnel manually to listen on a certain TCP port on his/her machine and forward it to a certain TCP port on the remote server.

Additionally, a ssh tunnel connects to one remote computer whereas a VPN can connect to a remote network.

For example:

A remote user Alice configures a ssh tunnel to connect to a web server at the office. She will configure her laptop's ssh client to listen on a specific port (for example 1080) and forward all traffic received on that port to port 80 of the remote server (the replies from the server will also travel through this tunnel). If she now wants to check emails, she will have to either connect unencrypted over the Internet or create another ssh tunnel to her office mail server.

Remote user Bob on the other hand configures his laptop to use a VPN back to the office. He can now access all the office servers as if he was located on the office LAN. Of course, there are many VPNs available and they can be configured in different ways, but if configured correctly, he can now browse the company intranet and check emails as if he was located in the office, without starting a new VPN for each application.

  • You can tunnel IP (or anything) in ssh as well. See the -w option. You can use ssh as a VPN. – Stéphane Chazelas Apr 4 '15 at 18:31
  • @StéphaneChazelas - As in the TCP over TCP "Poor Man's VPN"? Is it worth mentioning? I've never used it, but I understand it's by no means a high performance VPN solution. – garethTheRed Apr 4 '15 at 18:48
  • It's a TCP based VPN, like any TCP based VPN. It generally requires root access on the server to be able to use it with an out-of-the-box ssh. See also the SOCKS5 feature for one that doesn't require superuser privilege on neither end. – Stéphane Chazelas Apr 4 '15 at 19:20

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