SSH像端口转发但是有身份验证?


4
ssh user@server -R server:port1:localhost:port2   

这样ssh会将请求转发到server:port1到localhost:port2,但是任何人都可以连接到server:port1。

所以我想知道有什么可以做到这一点,但同时支持身份验证?


1
什么认证?您不能简单地在TCP级别上进行身份验证。
Jakuje 2017年

@Jakuje所以这在技术上是不可能的?
David Dai

1
如果你这样陈述,不。如果仅创建转发localhost,则需要对server使用进行身份验证,ssh然后才能连接到localhost端口,如果这样就足够了。
Jakuje

Answers:


0

您可以使用本地计算机上的另一个ssh隧道轻松完成此操作。

首先,您必须使用iptables 阻止与服务器的port1的外部连接:

iptables -A INPUT -p tcp --dport port1 -i eth0 -j DROP

其中eth0是您的WAN端口。

然后从本地端口5000在服务器的port1创建直接隧道,这一步需要身份验证

ssh -L user@server 5000:localhost:port1

现在,您可以连接到本地计算机的5000端口,就像连接到server:port1一样。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.