Find the answer to your Linux question:
Results 1 to 8 of 8
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2003
    Posts
    8

    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
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Hi,

    You can use an SSH tunnel like this:

    From the remote end, the user needs to connect to you like this:
    Code:
    ssh -oServerAliveInterval=150 -nNT -R 12345:localhost:22 1.2.3.4
    that assumes that your ip address is 1.2.3.4. 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:
    Code:
    ssh -oStrictHostKeyChecking=no user@localhost -p 12345
    to connect and log in using the pre-established connection.

  3. #3
    Just Joined!
    Join Date
    Sep 2003
    Posts
    8
    I tried your suggestion, I have no problem connecting to the server with the first command, however running the second command:

    Code:
    ssh -oStrictHostKeyChecking=no user1@localhost -p 12345
    gives me the following error
    Code:
    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:
    Code:
    user1@machine1
    user1@machine2
    user1@localhost
    none of them work.
    Last edited by atreyu; 11-16-2012 at 09:27 PM. Reason: added code tags for readability

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    on the machine that you started the tunnel on, what does this ps command report?
    Code:
    ps auxww|grep 'ssh .*localhost'|grep -v grep
    you should see something like:
    Code:
    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:
    Code:
    ssh -oStrictHostKeyChecking=no user1@localhost -p 12345
    it is assumed that "localhost" resolves to 127.0.0.1 (in /etc/hosts).

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

  5. #5
    Just Joined!
    Join Date
    Sep 2003
    Posts
    8
    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
    Code:
    1000      3348  0.1  0.1  41444  2848 pts/2    S+   14:23   0:00 ssh -oServerAliveInterval=150 -nNT -R 12345:localhost:22 192.168.1.11
    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
    Code:
    sshd[1363]: channel 2: open failed: connect failed: Connection refused

    Any other help will be greatly appreciated.

  6. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    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.

  7. #7
    Just Joined!
    Join Date
    Sep 2003
    Posts
    8
    Neither of the files have any entries...

  8. #8
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    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):
    Code:
    iptables -L
    also, depending on your distro, this one will show you the currently running iptables rules, if running:
    Code:
    iptables-save
    also, did you check the syslogs for login attempts? check here for the syslog (is distro dependent):
    Code:
    /var/log/messages
    /var/log/syslog
    also is this log for Red Hat based distros:
    Code:
    /var/log/secure

Posting Permissions

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