Host = * ControlMaster = auto ControlPath = /home/javafan/.ssh/ssh_%h_%p_%r Host = gateway1 HostName = gateway1.example.com User = javafan ForwardAgent = yes ServerAliveInterval = 60 Host = gateway2 Hostname = gateway2.example.com User = javafan ForwardAgent = yes ProxyCommand = ssh gateway1 nc %h %p Host = *.example.com ForwardAgent = yes User = javafan ProxyCommand = ssh gateway2 nc %h %p