SSH Tunnel com socat e tor

2

Estou tentando acessar meu servidor de desenvolvimento usando socat para criar um túnel, como este:

# start TOR
tor

# create tunnel
socat TCP-LISTEN:4141 SOCKS4A:localhost:remotehost:22,socksport=9050

# login through local tunnel
ssh localhost -p 4141

Esta é a saída quando o ssh é usado normalmente:

$ 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: 

Mas quando eu tento ssh usando o tunel socat, eu entendo isso:

$ 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

Além disso, quando isso acontece, o socat sai com:

2013/07/03 13:30:08 socat[9650] E connect(3, AF=2 127.0.0.1:9050, 16): Connection refused

Alguma idéia?

    
por Alain Jacomet Forte 03.07.2013 / 19:48

1 resposta

1

Tente usar as torsocks em vez de socat. Torsocks baseados em tsocks proxifier para Tor:

# dpkg -l torsocks
ii  torsocks      1.2-3    amd64   use SOCKS-friendly applications with Tor
# torsocks ssh user@server
#Enter a password

# Welcome !

shell:~/$ who
me pts/16       2013-08-31 22:41 (tor2.tedesca.net)

Eu sou de: tor2.tedesca.net

    
por 01.09.2013 / 00:57