进阶ssh设定档 [英] Advance ssh config file

查看:109
本文介绍了进阶ssh设定档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何直接SSH到远程服务器,下面是详细说明.

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

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

无法从本地计算机直接访问远程服务器,并且禁用Jump2 只能从Jump2访问远程服务器

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

远程服务器没有sshkegen,我们必须手动输入密码.

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

Local Machine通过IP和端口2222访问Jump1,然后从Jump 1通过主机名默认端口22访问Jump2.

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.

使用ssh/config文件,我们可以毫无问题地访问jump2服务器.但是我的要求是直接访问远程服务器.

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.

登录

 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.

我的配置文件

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

推荐答案

设置您的~/.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

或使用新的OpenSSH 7.3:

Or with new OpenSSH 7.3:

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

然后您可以简单地使用ssh RemoteServer

Then you can connect simply using ssh RemoteServer

这篇关于进阶ssh设定档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆