<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Ssh-tunneling - Revision history</title>
		<link>https://www.slackwiki.com/index.php?title=Ssh-tunneling&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.40.0</generator>
		<lastBuildDate>Wed, 08 Apr 2026 14:25:10 GMT</lastBuildDate>
		<item>
			<title>Erik: Copy from old</title>
			<link>https://www.slackwiki.com/index.php?title=Ssh-tunneling&amp;diff=193&amp;oldid=prev</link>
			<guid isPermaLink="false">https://www.slackwiki.com/index.php?title=Ssh-tunneling&amp;diff=193&amp;oldid=prev</guid>
			<description>&lt;p&gt;Copy from old&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sometimes you want to run vnc on a remote machine and do not have the&lt;br /&gt;
port forwarded, but you have ssh forwarded. This is a time where ssh&lt;br /&gt;
tunneling would work great. It's fast, efficient and its&lt;br /&gt;
encrypted. This first example is when you connecting to the server or&lt;br /&gt;
client that is running a vnc server:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ssh -L 5901:localhost:5901 user@server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the first -L means that we are going to tunnel from the&lt;br /&gt;
localhost to the actual remote host. The first field is ''5901'', the localport to use,&lt;br /&gt;
so that when we type '''localhost:5901''' we actually go through the tunnel (on the vnc client).&lt;br /&gt;
The next field is ''localhost'' which is resolved on the remote host side. So, localhost in this&lt;br /&gt;
example would be the remote host (who said it's confusing ?). The last field ''5901'' is the&lt;br /&gt;
port number on the remote host that we want to connect to.&lt;br /&gt;
The user@server is the username and host we want to forward to.&lt;br /&gt;
&lt;br /&gt;
Now if we wanted to forward port 631 on the remote host, but it is only binded on the hostname ''server'' the following example would be used:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ssh -L 9000:server:631 user@server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Port 631 is usually used for CUPS so we can tunnel this as well. So in&lt;br /&gt;
order to get that page we would type http://localhost:9000. This would&lt;br /&gt;
go through the tunnel and get the cups server remotely. Keep in mind&lt;br /&gt;
if you type a password it will be encrypted. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ssh -R 9000:localhost:3128 user@server2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now in this example we are going to forward a remote port to the local&lt;br /&gt;
box. For instance the above example we are going to open up port 9000&lt;br /&gt;
on server2 and it is going to tunnel to port 3128. This is the same&lt;br /&gt;
syntax as the -L option just the other way around for tunneling. The&lt;br /&gt;
best explanation between -L and -R is that -R is remotely opening up&lt;br /&gt;
the port 9000 while -L is locally opening that port up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now say you are already in an ssh session and want to add ports later&lt;br /&gt;
on? Well this is possible through what we call the SSH escape&lt;br /&gt;
key. Make sure you are on a new line and type ~C in and you should&lt;br /&gt;
see:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ssh&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you can run the commands -L and -R. These are the same syntax&lt;br /&gt;
above just do not put the ssh in front of it.So for instance you could&lt;br /&gt;
type:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -L 8000:localhost:631 server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And if it happened successfully it would say:&lt;br /&gt;
&lt;br /&gt;
Forwarding port &lt;br /&gt;
&lt;br /&gt;
Now hit enter after it says Forwarding port because sometimes it just&lt;br /&gt;
hangs there, but it forwards it fine. There are also more things you&lt;br /&gt;
can do with the ~ key. All you have to do is type ~?. (Note do not&lt;br /&gt;
type the . after the ?) &lt;br /&gt;
&lt;br /&gt;
Adding tunneling to ssh is great, but you can also make a socks proxy&lt;br /&gt;
out of ssh as well:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ssh -D 7800 user@server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then you can use your localhost:7800 as your socks proxy. Now say you&lt;br /&gt;
want other computers to be able to connect to your forward ports or&lt;br /&gt;
the socks proxy? Thats possible with the -g argument:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ssh -gD 8700 user@server&lt;br /&gt;
 ssh -gL 8000:localhost:3128 user@server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Both of these examples would allow a remote user to connect to&lt;br /&gt;
them.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</description>
			<pubDate>Sat, 06 Jun 2009 23:30:34 GMT</pubDate>
			<dc:creator>Erik</dc:creator>
			<comments>https://www.slackwiki.com/Talk:Ssh-tunneling</comments>
		</item>
</channel></rss>