繁体   English   中英

在需要访问远程应用程序端口的服务器上创建SSH隧道

[英]Create an SSH tunnel on the server that needs to access the remote application port

我正在开发Node.js应用程序。 以及新的Linux系统。 我将RethinkDB安装到Google Compute Engine实例。 我可以在本地访问28015驱动程序端口。 但是我无法访问驱动程序端口(28015),因此无法从外部访问它。 所以我在命令下面做了。 但是我有一些错误。

test@rethinkdbserver:~$ sudo iptables -A INPUT -i eth0 -p tcp --dport 28015 -j DROP
test@rethinkdbserver:~$ sudo iptables -I INPUT -i eth0 -s 127.0.0.1 -p tcp --dport 28015 -j ACCEPT
test@rethinkdbserver:~$ ssh -L 28000:localhost:28015 100.100.63.63
The authenticity of host '100.100.63.63 (100.100.63.63)' can't be established.
ECDSA key fingerprint is cc:21:56:de:f1:72:j3:64:50:k4:0b:42:e2:5f:db:63.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '100.100.63.63' (ECDSA) to the list of known hosts.
Permission denied (publickey).

我收到此错误:

无法建立主机“ 100.100.63.63(100.100.63.63)”的真实性。 ECDSA密钥指纹为cc:21:56:de:f1:72:j3:64:50:k4:0b:42:e2:5f:db:63。 您确定要继续连接(是/否)吗? 是警告:将“ 100.100.63.63”(ECDSA)永久添加到已知主机列表中。 权限被拒绝(公钥)。

RethinkDB手册文件

使用SSH隧道首先,保护驱动程序端口,以使其无法从外部访问。 在基于unix的系统上,可以使用iptables如下阻止端口:

sudo iptables -A INPUT -i eth0 -p tcp --dport 28015 -j DROP 
sudo iptables -I INPUT -i eth0 -s 127.0.0.1 -p tcp --dport 28015 -j ACCEPT

注意:如果您正在使用其他接口或未使用默认驱动程序端口,则可能必须替换上面的eth0和28015。 现在,在需要访问远程RethinkDB驱动程序端口的服务器上创建SSH隧道:

ssh -L <local_port>:localhost:<driver_port> <ip_of_rethinkdb_server>

哪里,

local_port是您要在驱动程序中指定的端口-它可以是服务器上任何可用的端口。

driver_port是RethinkDB驱动程序端口(默认为28015)。

ip_of_rethinkdb_server是运行RethinkDB服务器的服务器的IP地址。

现在,您可以通过连接到主机localhost和端口local_port来连接到RethinkDB实例:

完整文档https://rethinkdb.com/docs/security/

请帮忙

默认情况下,如果您不提供用户名,则SSH将假定您在本地计算机上使用用户名。 在这种情况下进行test 您应该将SSH隧道命令更改为:

ssh -L 28000:localhost:28015 user_name@100.100.63.63

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM