Questions tagged [ssh-tunneling]

An SSH tunnel provides an encrypted channel based on the SSH protocol.

The SSH tunnel is a form of tunneling protocol in which TCP traffic originating and meant to certain TCP ports is transferred in packets labeled with completely different port numbers. The actual source and destination ports are transferred in the payload of the packets.

For example, a tunnel between TCP port 1234 on the host machine and 4321 on the destination machine can be achieved with:

[me@host]$ ssh -L 1234:localhost:4321 me@destination

Where the localhost parameter defines the address to which the port will be bound on the host machine. In other words, traffic destined to localhost:1234 will be transferred over the ssh connection and given to the destination machine as if it had arrived at port 4321 on the destination machine.

An SSH tunnel allows for the transfer of unencrypted traffic over a secure (encrypted channel). All traffic passes through the single TCP connection between an ephemeral port on the host machine and the port 22 (or another port if ssh is running on a non-standard port). And it is treated as any other SSH traffic, and encrypted with SSL/TLS accordingly.

SSH tunneling is often used to bypass limitations with NATs and firewalls, which may limit the access to certain ports on a destination machine.


A reverse SSH tunnel can be achieved with -R, for example:

[me@host]$ ssh -R 1234:localhost:4321 me@destination

Will have the effect that traffic directed to localhost:1234 on the destination machine will be passed to the host machine as if it had arrived on port 4321 on the host machine.

682 questions
478
votes
5 answers

How does reverse SSH tunneling work?

As I understand this, firewalls (assuming default settings) deny all incoming traffic that has no prior corresponding outgoing traffic. Based on Reversing an ssh connection and SSH Tunneling Made Easy, reverse SSH tunneling can be used to get around…
Ali
  • 5,261
  • 5
  • 20
  • 18
286
votes
28 answers

SSH tunneling error: "channel 1: open failed: administratively prohibited: open failed"

When I open this ssh tunnel: ssh -nXNT -p 22 localhost -L 0.0.0.0:8984:remote:8983 I get this error when trying to access the HTTP server running on localhost:8984: channel 1: open failed: administratively prohibited: open failed What does this…
Neil
  • 3,402
  • 2
  • 17
  • 15
125
votes
3 answers

SSH: tunnel without shell on ssh server

I have to set up a tunnel between two hosts. For this I use ssh in this way: ssh -L MY_LOCAL_PORT:FOREIGN_ADDRESS:FOREIGN_PORT MYUSER@SSH_SERVER after that, I log in to my SSH_SERVER. How can I avoid this feature?! I have only to set up a tunnel. I…
Bau Miao
  • 1,473
  • 2
  • 11
  • 10
113
votes
7 answers

How to kill SSH session that was started with the -f option (run in background)

I'm pretty lost on this. From the man page: -f Requests ssh to go to background just before command execution. After starting SSH with the -f option, I have a working tunnel. But after I finish using it I don't know how to further interaction…
MountainX
  • 17,168
  • 59
  • 155
  • 264
45
votes
3 answers

Give server access to Internet, via client connecting by SSH

I can use my home computer A to connect by SSH to a server B where access to the external network is blocked. In other words, all requests to Internet from B throw an error: Network is unreachable. Can I redirect all these requests to pass through…
A.L
  • 1,492
  • 3
  • 15
  • 29
44
votes
4 answers

ssh into a server which is connected to a VPN service

I have a virtual private server, which I would like to run a web server while my server is connected to a VPN service When the VPN connection to my provider is not up, I can do anything I want with this server, ssh, scp, http etc. Once the openvpn…
Scott
  • 483
  • 1
  • 5
  • 8
37
votes
6 answers

Can I pipe /dev/video over ssh

I have two computers, a desktop in my office ( with a webcam attached ) and a laptop somewhere else on the network. Usually I take a look at my office through my webcam by running ssh Office -Y "mplayer tv://device=/dev/video0" from my laptop. I…
Stefan
  • 24,830
  • 40
  • 98
  • 126
36
votes
2 answers

Correct ssh config file settings to tunnel to a 3rd machine

I'm trying to tunnel to a server via a bridge server. So far, I've been able to get it working from the command shell properly using the following command: ssh -A -t [email protected] ssh -A [email protected] But I've…
Eric B.
  • 635
  • 2
  • 7
  • 11
32
votes
4 answers

How can I forward sound over VNC?

I use TightVNC and Remmina Remote Desktop to connect my Raspberry Pi to my Ubuntu laptop over VNC. It works great for the most part, except for the fact that there is no sound. I have googled all over the place, looking up forwarding sound over…
RPiAwesomeness
  • 980
  • 2
  • 8
  • 10
31
votes
3 answers

ssh port forward to access my home machine from anywhere

I'm coming from this question: https://superuser.com/questions/359799/how-to-make-freebsd-box-accessible-from-internet I want to understand this whole process of port forwarding. I read so many things, but am failing to understand the very basic…
hari
  • 2,400
  • 4
  • 21
  • 22
30
votes
1 answer

SSH Tunnel in background

I have a process that expects an ssh tunnel connection to execute correctly and I have been using the following command: ssh -L localhost:3306:127.0.0.1:3306 username@ -N & I have ran this successfully for 8 months,…
develop4fun2011
  • 403
  • 1
  • 4
  • 5
23
votes
1 answer

Reverse ssh tunnel in config

How can I establish a reverse ssh tunnel with my ./ssh/config file? I'm trying to reproduce this command ssh -R 55555:localhost:22 user@host in my .ssh/config file so that when I type ssh host I'll ssh to the host as user and with a reverse tunnel.…
Praxeolitic
  • 1,638
  • 3
  • 18
  • 24
22
votes
4 answers

How do I know if my ssh tunnel is created successfully?

I rely on the following script tunnel.sh written by others to keep a ssh tunnel alive: #!/bin/bash export SSH_HOST=tim@server if [ ! -f /tmp/.tunnel ] then echo "Creat SSH tunnel" ssh -f -D 9999 $SSH_HOST "if [ -f ~/.tunnel ]; then rm ~/.tunnel;…
Tim
  • 98,580
  • 191
  • 570
  • 977
21
votes
1 answer

How to setup port redirection after a ssh connection has been opened?

I'm using openssh on both client and server. I know I can run ssh -L or ssh -R to setup some port redirections over ssh. However, since they are command-line parameters, such redirections must be written before the connection is opened. Can I setup…
Denilson Sá Maia
  • 1,707
  • 2
  • 13
  • 14
19
votes
3 answers

ssh to private-ip

I have a computer with CentOS (computer A) that configured as has an private ip 10.150.5.141 (with restricted firewall), can access internet and my ArchLinux VPS (computer B) with real ip w.x.y.z How can I make another pc (computer C) that could…
Kokizzu
  • 9,257
  • 12
  • 55
  • 82
1
2 3
45 46