我想使用 ssh 端口转发。我已经好几年没用过这个功能了,所以我可能忘记了一些显而易见的事情,或者操作系统的默认设置可能已经改变了。
我在三台不同的机器上尝试过这个(都是 Ubuntu 9.10)。调试显示它正在打开端口进行监听。它们必须立即悄无声息地消失。
我已经检查过我可以从本地机器访问 192.168.1.8:80。
原因可能很简单,但我在谷歌搜索了 20 分钟后也没有找到它。
知道问题可能出在哪里吗?
谢谢,
克里斯。
root@chris-desktop:~# ssh -v -L 3142:192.168.1.8:80 yellow.example.com
OpenSSH_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to yellow.example.com [199.82.114.103] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-6ubuntu2
debug1: match: OpenSSH_5.1p1 Debian-6ubuntu2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-6ubuntu2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'yellow.example.com' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:9
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: Local connections to LOCALHOST:3142 forwarded to remote address 192.168.1.8:80
debug1: Local forwarding listening on ::1 port 3142.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 3142.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_GB.UTF-8
Linux yellow 2.6.31-17-server #54-Ubuntu SMP Thu Dec 10 18:06:56 UTC 2009 x86_64
To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
System information as of Thu Feb 18 09:31:36 GMT 2010
System load: 0.0 Memory usage: 51% Processes: 96
Usage of /: 1.3% of 194.04GB Swap usage: 0% Users logged in: 0
Graph this data and manage this system at https://landscape.canonical.com/
18 packages can be updated.
13 updates are security updates.
Last login: Thu Feb 18 09:26:14 2010 from gate.example.com
root@yellow:~# ~#
The following connections are open:
#2 client-session (t4 r0 i0/0 o0/0 fd 6/7 cfd -1)
root@yellow:~# netstat -lntp | grep 3142
root@yellow:~#
答案1
我不太明白您想要实现什么。也许您混淆了-L
switch 和-R
switch?
答案2
您正在转发
chris-desktop:3142 to 192.168.1.8:80 via the sshd process on yellow.example.com
输出
root@yellow:~# netstat -lntp | grep 3142
root@yellow:~#
符合预期。没有任何内容正在监听,yellow:3142
因为 上的 连接192.168.1.8:80
由 上的 sshd 进程管理yellow
。
执行时你应该看到一个监听过程
root@chris-desktop:~# netstat -lntp | grep 3142