To keep an ssh connection with a tunnel for port forwarding up reliably we can use the autossh command by Carson Harding. If the connection drops, autossh will restart it. Here’s a quick recipe to forward local port 33306 to a remote MySQL host listening on port 3306: Continue reading Keeping SSH Tunnels Up With Autossh
First, make sure you can use public key authentication or similar means to connect to ssh servers without typing in your password all the time.
First, create a key-pair with ssh-keygen. This is a one-time operation.
ssh-keygen -t dsa
It is good practice to enter a good password, but you may also leave the password empty. That will leave your private key vulnerable to local attacks, but if you need to login somewhere from a cron job, you probably need to do that.
Ths SSH protocol supports tunneling arbitrary ports from your local host to a remote network that is only reachable through a remote gateway machine. The typical situation is that you have a, say, web server in a network which is only accessible from inside the network. If you have an ssh gateway machine within the network, you can get to the web server using tunneling. Continue reading SSH tunneling your way through multiple gateways
An SSH server can be handy on a Windows machine, too. Cygwin comes with OpenSSH, and provides a lot of useful tools which you can use over the SSH connection. Here’s how to install Cygwin and OpenSSH server on a Windows machine.