What is the difference between SSH and SSH Tunneling

11,262

Solution 1

If you add tunneling to your SSH session, there is an additional data stream created for the tunnel over the same encrypted connection. You also can create more than one tunnel or don't start an interactive session (with the -N parameter). So, basically, there is no real difference, just different methods to use the encrypted connection.

Solution 2

SSH is really a generic secure communication mechanism which can transport arbitrary data over an insecure underlying channel. By default this data is a shell session (i.e. your local terminal is connected to a shell running on the remote system), but there are different types of data which can be transported.

One such type is a stream socket connection (e.g. a TCP connection), which is called tunnelling. The SSH client listens on a TCP port and transports any connections made to that port over the secure channel and exits the connection from the remote system.

By default when you setup a tunnel you still get a shell, i.e. the SSH client is transporting two types of data over the same connection (the tunnel and the shell). You can disable the shell with the -N parameter.

Share:
11,262
newbie
Author by

newbie

Updated on September 18, 2022

Comments

  • newbie
    newbie over 1 year

    As the title says, I don't really understand the difference between them. For example, if I connect to a specific server through SSH without tunneling I get the same shell as I get with tunneling.

    • Admin
      Admin about 11 years
      In a few years you'll regret the username choice. :D
  • newbie
    newbie about 11 years
    So from my understanding, using a regular SSH session without tunneling will connect to the server through the regular SSH port (22) while using the SSH tunneling will give me the option to connect to the server through other port. If Im correct, you can bypass firewalls with SSH tunneling but with a regular SSH connection you cant ?
  • FooBee
    FooBee about 11 years
    Don't make a difference between "regular" and "tunneled" connections, there isn't any. Oversimplified, your "regular" SSH connection isn't much else than a shell ("telnet") session tunneled through an encrypted SSH connection. A lot of things are possible with SSH, including bypassing firewalls, but only if the firewall is configured to allow this and if you have a shell with your SSH connection isn't important in the end.
  • newbie
    newbie about 11 years
    Im very sorry but I still cant understand this. Let`s take this scenario: I want to connect to an arbitrary server with SSH protocol but a Firewall stands between me and the server which blocks the SSH port (22). Now, The only way to establish the connection will be through Tunneling (while still using the SSH protocol) ?
  • mgorven
    mgorven about 11 years
    @newbie Glad it helped. You should accept the most useful answer by clicking the checkmark next to it.
  • FooBee
    FooBee about 11 years
    If port 22 is blocked, I can't use SSH at all. Not for a shell session and not to create a tunnel for some other connection, because with SSH everything is going over the same connection and if this connection is blocked, I can't use it.