2004-12-06, 05:30 AM
Some handy SSH tips:
Tunnel your remote machine's POP port to your local machine so you can pop your mail without passing your username/password in the clear:
ssh -f -L9000:remote.example.com:110 remote.example.com 'sleep 30 &'
This will make a tunnel from machine remote.example.com's port 110 to your local machine's port 9000. Point your mail client or fetchmail to localhost port 9000 and pop away. The connection will close and go away when your pop session ends so this setup is a one time thing. The "sleep 30 &" will keep the connection open for 30 seconds to give you a chance to start your pop session.
To setup a tunnel for nntp (usenet) that will stay up until you kill it:
ssh -N -f -L9100:news.example.com:119 remote.example.com
This will create a tunnel from your machine to remote.example.com and from there, open a non-encrypted connection to your news server (news.example.com). The -N and -f options start a non-terminal connection and puts the process in the background. I use this connection because my isp only allows connections to the news server from the isp's network. In the above example, remote.example.com would be a machine on my isp's network that is allowed to connect to the news server. The example above only allows access from the local machine's loopback address. (ie., localhost). If you want other machines to also be able to use the tunnel, you can add the "-g" option to the command and they will be able to direct a connection to port 9000 on your local machine to access the news server.
Assume you have a machine inside a firewall with no access from the external network and you want to be able to ssh into this machine from your home machine to finish the job you are working on. The following example shows one way to accomplish this.
ssh -N -f -R9000:remote.example.com:22 remote.example.com
on the remote machine, start a ssh connection like this:
ssh -p 9000 localhost
and you will initiate a session back to the internal machine.
Some good SSH links:
AUUG Winter 2002
SSH tips, tricks and protocol tutorial
[/url]http://www.mindrot.org/~djm/auug2002/ssh-tutorial.pdf
Secure Shell - Tips & Tricks
* X11 Forwarding
* Seamless Authentication
* TCP Port Forwarding
http://oregonstate.edu/~creliar/ssh/ssh-tips.shtml
SSH Tips
* X11 Forwarding
* Authentication
http://socrates.yi.org/index.php?page=SshTips
SSH Tips and Tricks
* Security
* tcp forwarding
* X-Windows
* Config File Problems
* SSH over SMB
http://heimhardt.com/htdocs/ssh-tips-and-tricks.html
The OpenSSH FAQ
[url=http://www.openssh.com/faq.html]http://www.openssh.com/faq.html
Have fun.
P38