我正在开发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是运行该服务器的服务器的IP地址 RethinkDB服务器。
现在可以通过连接到主机localhost和端口local_port来连接到RethinkDB实例:
完整文件 https://rethinkdb.com/docs/security/
请帮忙
答案 0 :(得分:1)
默认情况下,如果您不提供用户名,SSH将假定您使用的是本地计算机上的用户名。在这种情况下test
。您应该将SSH隧道命令更改为:
ssh -L 28000:localhost:28015 user_name@100.100.63.63