Find the answer to your Linux question:
Results 1 to 8 of 8
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question Using an ssh connection to connect back to workstation??

    Hello all, Is there a way that a user can connect to my ssh server from a workstation and then I would like to use that connection to somehow connect back to the workstation?

    The reason I can't connect from my computer to the user's computer, is because of gateway issues on the user's side.

    I have done something similar using vnc programs in windows, so I know it is possible to somehow make this work in linux. My ultimate goal would be to make the vnc thing work similarly for linux, so if anybody can provide direction on either problem it would be greatly appreciated.

  2. #2

    You can use an SSH tunnel like this:

    From the remote end, the user needs to connect to you like this:
    ssh -oServerAliveInterval=150 -nNT -R 12345:localhost:22
    that assumes that your ip address is The command will bind the remote user's port 12345 to the SSH connection on port 22 (the default).

    then from your machine, you can do:
    ssh -oStrictHostKeyChecking=no user@localhost -p 12345
    to connect and log in using the pre-established connection.

  3. #3
    I tried your suggestion, I have no problem connecting to the server with the first command, however running the second command:

    ssh -oStrictHostKeyChecking=no user1@localhost -p 12345
    gives me the following error
    ssh_exchange_identification: Connection closed by remote host
    not sure what machine the user1 is supposed to exists, anyways user1 exists in both machines, and I've also changed the command for both machines, like so:
    none of them work.
    Last edited by atreyu; 11-16-2012 at 09:27 PM. Reason: added code tags for readability

  4. $spacer_open
  5. #4
    on the machine that you started the tunnel on, what does this ps command report?
    ps auxww|grep 'ssh .*localhost'|grep -v grep
    you should see something like:
    user1  29724  0.0  0.1  75380  3148 ?        S    00:05   0:00 ssh -oServerAliveInterval=150 -nNT -R 12345:localhost:22 <remote_ip_address>
    then on the other machine (the one who's ip address is <remote_ip_address> above), you do:
    ssh -oStrictHostKeyChecking=no user1@localhost -p 12345
    it is assumed that "localhost" resolves to (in /etc/hosts).

    check /var/log/messages and /var/log/secure on the first machine for clues.

  6. #5
    Thanks for all your help, however I'm still unable to make the connection,
    I have followed your suggestion and ran the ps command and I can see exactly as the output example you posted
    1000      3348  0.1  0.1  41444  2848 pts/2    S+   14:23   0:00 ssh -oServerAliveInterval=150 -nNT -R 12345:localhost:22
    I have monitored both machines' logs and the only thing I could see in the machine I am runing the second command is the following message in the auth.log
    sshd[1363]: channel 2: open failed: connect failed: Connection refused

    Any other help will be greatly appreciated.

  7. #6
    How about the firewall, is that running on either host?

    Do you have TCP Wrappers configured? They would be in the /etc/hosts.allow and /etc/hosts.deny files.

  8. #7
    Neither of the files have any entries...

  9. #8
    Quote Originally Posted by seekndestroy View Post
    Neither of the files have any entries...
    okay, so tcp wrappers are not being used.

    what about the firewall? try this command (as root):
    iptables -L
    also, depending on your distro, this one will show you the currently running iptables rules, if running:
    also, did you check the syslogs for login attempts? check here for the syslog (is distro dependent):
    also is this log for Red Hat based distros:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts