高级 ssh 配置文件 [英] Advance ssh config file

查看:22
本文介绍了高级 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 我们访问 Jump1 ip 和端口 2222 然后从 Jump 1 我们访问 Jump2> 使用主机名默认端口 22.

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天全站免登陆