高级ssh配置文件
如何直接ssh到远程服务器,下面是详细说明高级ssh配置文件,ssh,ssh-tunnel,ssh-config,Ssh,Ssh Tunnel,Ssh Config,如何直接ssh到远程服务器,下面是详细说明 Local machine ---> Jump1 ----> Jump2 ----> Remote Server 从本地计算机无法直接访问远程服务器,Jump2被禁用 远程服务器只能从Jump2访问 远程服务器没有sshkegen,我们必须手动提供paswword 从Local Machine访问带有ip和端口2222的Jump1,然后从Jump1访问带有主机名默认端口22的Jump2 使用ssh/config文件,我们可以毫无问题
Local machine ---> Jump1 ----> Jump2 ----> Remote Server
从本地计算机无法直接访问远程服务器,Jump2被禁用
远程服务器只能从Jump2访问
远程服务器没有sshkegen,我们必须手动提供paswword
从Local Machine
访问带有ip和端口2222的Jump1
,然后从Jump1
访问带有主机名默认端口22的Jump2
使用ssh/config文件,我们可以毫无问题地访问jump2服务器。但我的要求是直接访问远程服务器
是否有任何可能的方式我不介意输入远程服务器的密码
日志
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:
Host RemoveServer
ProxyJump jump1user@Jump1,jump2user@Jump2
User remoteUser
然后,只需使用
ssh-RemoteServer
设置~/.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:
Host RemoveServer
ProxyJump jump1user@Jump1,jump2user@Jump2
User remoteUser
然后,您只需使用
ssh-RemoteServer
即可连接。除非在sshd-config中禁用了ssh-keygen,否则不需要远程服务器上的ssh-keygen来设置无密码身份验证。除非在sshd-config.My版本中禁用了ssh-keygen,否则不需要远程服务器上的ssh-keygen来设置无密码身份验证openssh-server-5.3p1
但是上面的配置文件示例不起作用。获取错误ssh:connect to host ip.address port 22:Connection timed out
对于跳转主机有一个用户,而对于远程服务器有另一个用户。设置LogLevel DEBUG3
并发布日志。哪种连接超时?为Jump1
添加Port
选项。不要使用ssh-vvv进行连接root@ip地址
。使用配置文件中定义的名称:ssh ff1bp-vsns0001n
。我的版本openssh-server-5.3p1
,但在上面的配置文件示例中它不起作用。获取错误ssh:connect to host ip.address port 22:Connection timed out
对于跳转主机有一个用户,而对于远程服务器有另一个用户。设置LogLevel DEBUG3
并发布日志。哪种连接超时?为Jump1
添加Port
选项。不要使用ssh-vvv进行连接root@ip地址
。使用配置文件中定义的名称:ssh ff1bp-vsns0001n
。