Using SSH keys for Password-less Logins
note: remember to run command: ssh-add
How to prevent SSH terminal timeout
As root on your desktop (or client) machine, edit /etc/ssh/ssh_config and add the line:
That will send send a message to the server every 60 seconds, keeping the connection open. I prefer this way because I login to several machines every day, and I don’t have root access to all of them.
Transparent Multi-hop SSH
1. when want to connect to a server through multiple proxies, we can input the following code to ~/.ssh/config
#ControlMaster auto #ControlPath /home/zheng/.ssh/tmp/%h_%p_%r Host irdut User yezheng HostName 188.8.131.52 #Host aoraki # ProxyCommand ssh -q ruapehu nc -q0 aoraki 22 Host 192.168.1.77 User yezheng ProxyCommand ssh -q irdut nc -q0 %h 22
- Host: Defines for which host or hosts the configuration section applies. The section ends with a new Host section or the end of the file.
- User: Defines the username for the SSH connection. Useful if your username on the remote host is different from your local username.
- HostName: Defines the literal hostname for the remote server. Useful if a nickname for the host is used in the Host line.
- ProxyCommand: Specifies the proxy command for the connection. This command is launched prior to making the connection to Hostname. %h is replaced with the host defined in HostName and %p is replaced with 22 or is overridden by a Port directive. "2> /dev/null" prevents nc's "Killed by signal 1." message when it exits.