SSH Tricks
Shell Scripts
Configurations
MRTG Configs
Nagios/Zenoss
SNMP V3

SSH FU
Create an SSH key for pubkey authentication
ssh-keygen -t dsa

Copy the key to the server you want to use pubkey authentication for.
scp ~/.ssh/id_dsa.pub
username@192.168.168.200:~/.ssh/authorized_keys

RDP (rdesktop to a host behind a firewall)
This command forwards port 3390 on your local PC to 3389 on 192.168.1.23. This is dependant upon your firewall accepting ssh on port 22 or have port 22 forwarded to a host running an ssh server behind your firewall.
ssh -l username www.hostname.com -L 3390:192.168.1.23:3389

Then run this on a linux system:
rdesktop -g 1024x768 -u username 127.0.0.1:3390 &
or run the remote desktop client on windows to host localhost:3390.

Proxy your webbrowser traffic through a SSH tunnel to your home network.

First start your SSH tunnel
You've got access to an SSH server and you want to start using it as your proxy. To do so, you're going to set up a "tunnel" which passes web traffic from your local machine to the proxy over SSH. The command to do so is:
ssh -ND 8080 username@www.hostname.com
Of course, you're going to replace the you with your username and hostname.com with your server domain name or IP address. What that command does is hand off requests to localhost, port 8080, to your server at hostname.com to handle.
When you execute that command you'll get prompted to enter your password. Once you authenticate, nothing will happen. The -N tells ssh not to open an interactive prompt, so it will just hang there, waiting. That's exactly what you want.

Second you'll need to set your internet browser proxy to localhost port 8080.

IMPORTANT NOTE: DNS lookups will not traverse this tunnel, if you are trying to do this from work or a restricted network your DNS request could get you busted. You have been warned!

Optional Step: DNS proxying through SOCKS5 in Firefox browser

This step is totally optional, but since you are going to be proxying the web traffic over the ssh tunnel then it just makes sense to proxy the DNS requests as well. If you tunnel your data through ssh and then still do requests against the local DNS server for the ip addresses then you have accomplished nothing.

To add a boolean option into the URL "about:config" page in Firefox. Create the entry "network.proxy.socks_remote_dns" and set it to true.
##Preference Name Status Type Value
network.proxy.socks_remote_dns user set boolean true

If you are using the Firefox extension "FoxyProxy" make sure you modify the "options" section under "miscellaneous" and check the option "use SOCKS proxy for DNS lookups." FoxyProxy will override the about:config option that you set above.


johnb at unixsamurai dot com