Use ssh tunnel to connect to the server through ProxyCommand

Open the ~/.ssh/configfile, if not, create a new one

Enter the following and save:

Host dxx.sxx-bastion                # jumpserver name
    hostname 54.65.xx.2xx           # jumpserver ip
    Port 18330                      # jumpserver port
    User ec2-user                   # jumpserver user name
Host dxx.sxx-web1                   # target server name
    hostname 10.0.x.xx              # target server ip
    ProxyCommand ssh dxx.sxx-bastion -W %h:%p  # ProxyCommand 
    User ubuntu                     # user name

After you complete the above configuration locally, you can directly connect to the dxx.sxx-web1 machine through the ssh command on the local machine (you don't need to log in to jumpsever first and then connect to the target server)

ssh -u [email protected]

Guess you like

Origin blog.csdn.net/lianshaohua/article/details/111589025