sshssh-tunnelssh-config

Advance ssh config file


How to ssh directly to Remote Server, below is the details description.

Local machine ---> Jump1 ----> Jump2 ----> Remote Server

From local machine there is no direct access to Remote Server and Jump2 is disable Remote Server can only be accessed from Jump2

There is no sshkegen to remote server we have to give the paswword manually.

from Local Machine we access the Jump1 with ip and port 2222 then from Jump 1 we access the Jump2 with host name default port 22.

With ssh/config file we were able to access the jump2 server without any problem. But my requirement is to directly access the remote server.

is there any possible way I don't mind entering the password for remote server.

Log

 ssh -vvv root@ip address
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to ip address [ip address] port 22.

My Config file

Host jump1
    Hostname ip.109
    Port 2222
    User avdy

Host jump2
    Hostname ip.138
    Port 22
    ProxyCommand ssh -W %h:%p jump1
    User avdy

Host remote-server
    Hostname ip.8
    Port 22
    ProxyCommand ssh -W %h:%p jump2
    User root

Solution

  • Set your ~/.ssh/config:

    Host Jump1
      User jump1user
      Port 2222
    Host Jump2
      ProxyCommand ssh -W %h:%p Jump1
      User jump2user
    Host RemoveServer
      ProxyCommand ssh -W %h:%p Jump2
      User remoteUser
    

    Or with new OpenSSH 7.3:

    Host RemoveServer
      ProxyJump jump1user@Jump1,jump2user@Jump2
      User remoteUser
    

    Then you can connect simply using ssh RemoteServer