ViLLaN
05-12-2004, 03:01 PM
Hey Guys,
Firstly, this is not a question.. I thought I would write up something quickly to help those of you behind secure networks (such as the one Im behind at the moment) as Ive been asked a number of times in the past, and I know there are a couple of us in this position. The idea of this post is to teach you how to access what ever you want from behind a corperate firewall, via the use of an SSH client and server, and tunneling data through this connection.
If anyone is interested, I can make an SSH server available to them for TESTING, not on a permanent basis.
Step 1 -
The first step in creating a working connection, is to evaluate your network, the applications you use day to day, and what ports they make use of for communication.
Example, if you are able to successfully use yahoo from work, chances are the administrators of the network have left 5050 open. If you can use FTP, port 21 is most likely open. If you want to find out the ports used by a particular program (and you are using Windows XP, the "netstat -a -o" command will show you which PID's are making connections to which ports. This information can be matched up with the task manager process tab, if you add the "pid" column.
Step 2 -
Narrow down your list of available ports, to protocols that cant be proxied, or arent as common. As an example, any proxy based firewall will be proxying HTTP, FTP, POP3, SMTP, DNS and many others. Yahoo, ICQ, ssh and lots of others will usually not be, either because a proxy hasnt been created (or in the case of encrypted protocols CANT be created).
Step 3 -
Create an SSH server on your computer computer, listening on one of the ports that you believe to be open, in this example we will stick to 5050. I wont go through the setup of an SSH server, firstly because of its relative ease, and also because of the wealth of information allready available.
I prefer Opensshd, or Winsshd on Windows machines, and the standard opensshd on Linux based machines. Opensshd is free and available for Windows machines, while winsshd is available for free for 30 days, and then they charge.
Step 4 -
Choose a client to use on your work machines. On Windows, there are a multitude available, Putty, SSH Secure Shell, Tunnelier and the list goes on. All are free for personal use, except for Tunnelier. Tunnelier is from the same manufacturer as Winshhd, and is actually a very handy product. If you are planning on using it for tunneling remote desktop connections, this may be the easiest for you to use.
The options we will be using relate to "Tunneling".
Putty :- Configuration > Connection > SSH > Tunnells
SSH Secure Shell :- Profile Settings > Connection > Tunneling
Tunnelier :- Options > R2C Tunneling
But more on that later.
Step 5 -
Your next step will be to setup a proxy. At this point, you have the server installed, you have chosen your client, and if things are working you should be able to make a connection between the two.. If you cant, go back and try a different port, as the one you are trying may not be available.
As far as proxy software goes, linux users have the pick of the bunch.. I wont even go into linux proxies, needless to say you have more available than you can poke a stick at it.. Choose your favourite. For Windows users, I prefer to the small proxy.exe from AnalogX, it gets the job done.
It doesnt really matter if you put the proxy server on the same machine as the SSH server, as long as they can communicate. If you allready have an internal proxy server at home, all the better.
Step 6 -
At this point you have all the software installed and setup, you should be able to get a connection up between your client and server. When you create an SSH tunnel, you are basically setting up the ssh client so it is listening at a local port on your computer, redirecting all traffic received at that port over the ssh connection, and telling the server at the end where to send the data to.. For example if we were trying to get MSN, YAHOO and ICQ to go through SSH and connect to an analogx proxy on the same machine as the ssh server -
Local Listening Port - 6588
Computer that the server should direct traffic to at the other end of the connection: localhost
Remote Port To Send Data to: 6588
This means that all data going to port 6588 on your local machine, will end up going to port 6588 of the remote machine on the other side of the ssh connection (which is where your proxy is waiting for connections).
All that is needed now, is to go into the options for any programs that you want to go through the proxy, and tell them a proxy is waiting at "localhost" on port "6588".
In my example, I use Gaim (a chat program that replaces the MSN, YAHOO and ICQ programs), and I tell it that I have a proxy on port 6588 of my own machine. Once I have the ssh connection up, all traffic is routed through the connection to an analogx proxy server on the other side, where it goes out on the internet. There are reasons why you would do this, even if you DID have access to these chat programs through your firewall.. Running them through an SSH tunnel means that they are encrypted, and dont become unencrypted till they leave your home proxy.. Which means no one in your corperation can read the traffic.
One last note to make with the tunnel, you dont have to do things through a proxy as in the example above, you can make the remote host what ever you like. For example, if I want to connect to ccgl's IRC address through my firewall (which doesnt allow it), I just set -
Local Port: 6667
Remote Address: irc.ccgl.org
Remote Port: 6667
So when I connect to port 6667 locally, it goes straight to port 6667 of irc.ccgl.org, and again, its encrypted, so you have some privacy..
Any questions, ask.. Any other ideas for things you would like to hear.. Ask :P Im happy to go into more details with any of the products listed in the writeup, whether it be installation, connection or tunneling..
Vi||aN
Firstly, this is not a question.. I thought I would write up something quickly to help those of you behind secure networks (such as the one Im behind at the moment) as Ive been asked a number of times in the past, and I know there are a couple of us in this position. The idea of this post is to teach you how to access what ever you want from behind a corperate firewall, via the use of an SSH client and server, and tunneling data through this connection.
If anyone is interested, I can make an SSH server available to them for TESTING, not on a permanent basis.
Step 1 -
The first step in creating a working connection, is to evaluate your network, the applications you use day to day, and what ports they make use of for communication.
Example, if you are able to successfully use yahoo from work, chances are the administrators of the network have left 5050 open. If you can use FTP, port 21 is most likely open. If you want to find out the ports used by a particular program (and you are using Windows XP, the "netstat -a -o" command will show you which PID's are making connections to which ports. This information can be matched up with the task manager process tab, if you add the "pid" column.
Step 2 -
Narrow down your list of available ports, to protocols that cant be proxied, or arent as common. As an example, any proxy based firewall will be proxying HTTP, FTP, POP3, SMTP, DNS and many others. Yahoo, ICQ, ssh and lots of others will usually not be, either because a proxy hasnt been created (or in the case of encrypted protocols CANT be created).
Step 3 -
Create an SSH server on your computer computer, listening on one of the ports that you believe to be open, in this example we will stick to 5050. I wont go through the setup of an SSH server, firstly because of its relative ease, and also because of the wealth of information allready available.
I prefer Opensshd, or Winsshd on Windows machines, and the standard opensshd on Linux based machines. Opensshd is free and available for Windows machines, while winsshd is available for free for 30 days, and then they charge.
Step 4 -
Choose a client to use on your work machines. On Windows, there are a multitude available, Putty, SSH Secure Shell, Tunnelier and the list goes on. All are free for personal use, except for Tunnelier. Tunnelier is from the same manufacturer as Winshhd, and is actually a very handy product. If you are planning on using it for tunneling remote desktop connections, this may be the easiest for you to use.
The options we will be using relate to "Tunneling".
Putty :- Configuration > Connection > SSH > Tunnells
SSH Secure Shell :- Profile Settings > Connection > Tunneling
Tunnelier :- Options > R2C Tunneling
But more on that later.
Step 5 -
Your next step will be to setup a proxy. At this point, you have the server installed, you have chosen your client, and if things are working you should be able to make a connection between the two.. If you cant, go back and try a different port, as the one you are trying may not be available.
As far as proxy software goes, linux users have the pick of the bunch.. I wont even go into linux proxies, needless to say you have more available than you can poke a stick at it.. Choose your favourite. For Windows users, I prefer to the small proxy.exe from AnalogX, it gets the job done.
It doesnt really matter if you put the proxy server on the same machine as the SSH server, as long as they can communicate. If you allready have an internal proxy server at home, all the better.
Step 6 -
At this point you have all the software installed and setup, you should be able to get a connection up between your client and server. When you create an SSH tunnel, you are basically setting up the ssh client so it is listening at a local port on your computer, redirecting all traffic received at that port over the ssh connection, and telling the server at the end where to send the data to.. For example if we were trying to get MSN, YAHOO and ICQ to go through SSH and connect to an analogx proxy on the same machine as the ssh server -
Local Listening Port - 6588
Computer that the server should direct traffic to at the other end of the connection: localhost
Remote Port To Send Data to: 6588
This means that all data going to port 6588 on your local machine, will end up going to port 6588 of the remote machine on the other side of the ssh connection (which is where your proxy is waiting for connections).
All that is needed now, is to go into the options for any programs that you want to go through the proxy, and tell them a proxy is waiting at "localhost" on port "6588".
In my example, I use Gaim (a chat program that replaces the MSN, YAHOO and ICQ programs), and I tell it that I have a proxy on port 6588 of my own machine. Once I have the ssh connection up, all traffic is routed through the connection to an analogx proxy server on the other side, where it goes out on the internet. There are reasons why you would do this, even if you DID have access to these chat programs through your firewall.. Running them through an SSH tunnel means that they are encrypted, and dont become unencrypted till they leave your home proxy.. Which means no one in your corperation can read the traffic.
One last note to make with the tunnel, you dont have to do things through a proxy as in the example above, you can make the remote host what ever you like. For example, if I want to connect to ccgl's IRC address through my firewall (which doesnt allow it), I just set -
Local Port: 6667
Remote Address: irc.ccgl.org
Remote Port: 6667
So when I connect to port 6667 locally, it goes straight to port 6667 of irc.ccgl.org, and again, its encrypted, so you have some privacy..
Any questions, ask.. Any other ideas for things you would like to hear.. Ask :P Im happy to go into more details with any of the products listed in the writeup, whether it be installation, connection or tunneling..
Vi||aN