在需要访问远程应用端口的服务器上创建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).
我收到这个错误:
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
注意:如果您使用其他接口或不使用默认驱动程序端口,则可能需要替换上面的 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 user_name@100.100.63.63
我正在开发 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
注意:如果您使用其他接口或不使用默认驱动程序端口,则可能需要替换上面的 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 user_name@100.100.63.63