ubuntu – 如何通过SSH隧道配置SSH连接的快捷方式

前端之家收集整理的这篇文章主要介绍了ubuntu – 如何通过SSH隧道配置SSH连接的快捷方式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我公司的生产服务器(FOO,BAR …)位于两个网关服务器(A,B)后面.为了连接到服务器FOO,我必须用我的用户名JOHNDOE打开与服务器A或B的ssh连接,然后从A(或B)我可以访问任何打开与标准用户名的SSH连接的生产服务器(让我们称之为威比).

所以,每次我必须做的事情如下:

ssh johndoe@a
...
ssh webby@foo
...
# now I can work on the server

你可以想象,当我需要使用scp或者我需要快速打开多个连接时,这是一个麻烦.

我已经配置了一个ssh密钥,而且我正在使用.ssh / config来获取一些快捷方式.

我想知道我是否可以创建某种ssh配置才能输入

ssh foo

让SSH为我打开/转发所有连接.可能吗?

编辑

womble的答案正是我所寻找的,但现在似乎我不能使用netcat,因为它没有安装在网关服务器上.

weppos:~ weppos$ssh foo -vv
OpenSSH_5.1p1,OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /Users/xyz/.ssh/config
debug1: Applying options for foo
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Executing proxy command: exec ssh a nc -w 3 foo 22
debug1: permanently_drop_suid: 501
debug1: identity file /Users/xyz/.ssh/identity type -1
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /Users/xyz/.ssh/id_rsa type 1
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /Users/xyz/.ssh/id_dsa type 2
bash: nc: command not found
ssh_exchange_identification: Connection closed by remote host
作为Kyle答案的更具体版本,您想要放在〜/ .ssh / config文件中的是:
host foo
  User webby
  ProxyCommand ssh a nc -w 3 %h %p

host a
  User johndoe

然后,当您运行“ssh foo”时,SSH将尝试SSH到johndoe @ a,运行netcat(nc),然后通过此隧道执行SSH到webby @ foo.魔法!

当然,为了做到这一点,需要在网关服务器上安装netcat;此软件包适用于所有主要发行版和操作系统.

原文链接:https://www.f2er.com/ubuntu/349026.html

猜你在找的Ubuntu相关文章