我正在尝试使用 socat 访问我的开发服务器来创建隧道,如下所示:
# start TOR
tor
# create tunnel
socat TCP-LISTEN:4141 SOCKS4A:localhost:remotehost:22,socksport=9050
# login through local tunnel
ssh localhost -p 4141
这是ssh正常使用时的输出:
$ ssh -v remotehost -p 22
OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to remotehost [remoteip] port 22.
debug1: Connection established.
debug1: identity file /home/alainus/.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 /home/alainus/.ssh/id_rsa-cert type -1
debug1: identity file /home/alainus/.ssh/id_dsa type -1
debug1: identity file /home/alainus/.ssh/id_dsa-cert type -1
debug1: identity file /home/alainus/.ssh/id_ecdsa type -1
debug1: identity file /home/alainus/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.1p1 Debian-4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA ...
debug1: Host 'remotehost' is known and matches the ECDSA host key.
debug1: Found key in /home/alainus/.ssh/known_hosts:5
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
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: Offering RSA public key: /home/alainus/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/alainus/.ssh/id_dsa
debug1: Trying private key: /home/alainus/.ssh/id_ecdsa
debug1: Next authentication method: password
alainus@remotehost's password:
但是当我尝试使用 socat 隧道进行 ssh 时,出现了以下信息:
$ ssh -vvv localhost -p 4141
OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 4141.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/alainus/.ssh/id_rsa" as a RSA1 public key
debug1: identity file /home/alainus/.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 /home/alainus/.ssh/id_rsa-cert type -1
debug1: identity file /home/alainus/.ssh/id_dsa type -1
debug1: identity file /home/alainus/.ssh/id_dsa-cert type -1
debug1: identity file /home/alainus/.ssh/id_ecdsa type -1
debug1: identity file /home/alainus/.ssh/id_ecdsa-cert type -1
ssh_exchange_identification: Connection closed by remote host
此外,当发生这种情况时,socat 会退出并显示:
2013/07/03 13:30:08 socat[9650] E connect(3, AF=2 127.0.0.1:9050, 16): Connection refused
有任何想法吗?