1

从我的本地计算机,我可以通过 SSH 访问服务器 A。一旦在服务器 A 上,我通过服务器 B 上的端口 3306 连接到服务器 B 上的 mysql。

mysql -h <B.hostname>  -P 3306 -u <username> -p

我没有从本地计算机或服务器 A 对服务器 B 的 ssh 访问权限。

我想做的是从我的本地机器访问服务器 B 上的 mysql。我发现的每个隧道/端口转发链接都假定我可以 ssh 进入服务器 B。

4

2 回答 2

3

ssh's -L takes a local port, a remote hostname to connect from the ssh server you connect to, and the remote port. In this case, you'll run:

ssh -L 3307:B.hostname:3306 A.hostname

This will make ssh connect to A, and when you later connect to port 3307 using a local mysql client (mysql -H localhost -P 3307 -u ...), A's sshd will initiate a connection to B.hostname:3306 for you.

于 2013-06-24T13:54:32.883 回答
0

Sounds like you have to use remote port forwarding. Try this on your local host:

[auto]ssh -R 1111:127.0.0.1:2222 -f -N -4Cp1234 username@servername.net

So you get on your localhost:2222 (local machine) everything you get on localhost:1111 (when you logged in on servername.net), with traffic going by SSH on servername.net:1234.

If your "server A" could access "server B" somehow, and you could access "server A" via SSH, that could probably help you.

于 2013-06-24T13:54:04.027 回答