gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 10:47:26 25 4
gpt4 key购买 nike

我正在开发 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).

我收到这个错误:

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).

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

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

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

在哪里,

local_port is the port you are going to specify in the driver - It can be any available port on your server.

driver_port is the RethinkDB driver port (28015 by default).

ip_of_rethinkdb_server is the IP address of the server that runs the RethinkDB server.

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

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

请帮忙

最佳答案

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


ssh -L 28000:localhost:28015 用户名@100.100.63.63

关于linux - 在需要访问远程应用端口的服务器上创建SSH隧道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32473650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com