Find the answer to your Linux question:
Results 1 to 7 of 7
Just a quick question about SSH. I currently have to ssh through an external gateway, and then from that machine ssh into my machine. I'm trying to make an alias ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    8

    SSH Question


    Just a quick question about SSH.

    I currently have to ssh through an external gateway, and then from that machine ssh into my machine.
    I'm trying to make an alias automatically ssh me into my computer once I've successfully ssh'd into the gateway.

    How would I go about doing this?

  2. #2
    Just Joined! dmk06's Avatar
    Join Date
    Jun 2010
    Location
    San Diego
    Posts
    37
    Quote Originally Posted by DrGlove View Post
    Just a quick question about SSH.

    I currently have to ssh through an external gateway, and then from that machine ssh into my machine.
    I'm trying to make an alias automatically ssh me into my computer once I've successfully ssh'd into the gateway.

    How would I go about doing this?
    Port forwarding on your router or gateway device.

    eg: externalIP: port-to-forward then have that port forwarded to localIP:22
    (good to disable root login and su to root )[/I] )

  3. #3
    Just Joined!
    Join Date
    May 2010
    Posts
    8
    Unfortunately, I am gaining access to a machine at work so I do not have access to the routers or have the ability to forward any ports.

    Also, the gateway is likely run via a liveCD for security (no write) and hence I have no home directory. Otherwise I'd create a simple alias such as: 'alias ss2alias='ssh internalmachine''

    and simply run (from my home computer):

    > ssh externalmachine ssh2alias

  4. #4
    Just Joined! dmk06's Avatar
    Join Date
    Jun 2010
    Location
    San Diego
    Posts
    37
    autossh - Automatically restart SSH sessions and tunnels
    Update: version 1.4b fixes a bug in polling, adds a max lifetime option and a compile-time option to touch the pid file on each connection test.

    Previous update: version 1.4a fixed a some Makefile bugs and an bug when creating a pid file.

    Previous update: version 1.4 fixed a few bugs, added options to have autossh create a pid file and send a small custom message to the remote echo service, and gave autossh basic autoconf support.

    FEATURES

    * autossh is a program to start a copy of ssh and monitor it, restarting it as necessary should it die or stop passing traffic. The idea is from rstunnel (Reliable SSH Tunnel), but implemented in C.
    * The author's view is that it is not as fiddly as rstunnel to get to work.
    * Connection monitoring using a loop of port forwardings or a remote echo service.
    * Backs off on rate of connection attempts when experiencing rapid failures such as connection refused.
    * Compiled and tested on OpenBSD, Linux, Solaris, Mac OS X, Cygwin, and AIX; should work on other BSDs.
    * Freeware.

    FUN

    * Use with "screen" for perpetual session (see included script "rscreen").

    DEFICIENCIES

    * Bugs still not found.

    BUILD
    If you use OpenBSD or FreeBSD, autossh is available in the ports tree, and as a package that can be FTP'd down. Cygwin and some Linux distros also have it available as a package.

    To build from source:

    * download autossh-1.4b.tgz (md5/sha1/rmd160)
    * gunzip -c autossh-1.4b.tgz | tar xvf -
    * cd autossh-1.4b
    * ./configure
    * make
    * copy binary to where you wish it, or "make install" will install it under /usr/local by default.
    * examine autossh.host for example wrapper script and options
    source: autossh

    more info on ssh tunneling:
    Breaking Firewalls with OpenSSH and PuTTY
    SSH Tunnelling (Port Forwarding) — RZG

  5. #5
    Just Joined!
    Join Date
    May 2010
    Posts
    8
    Thanks for the info dmk06, but I fail to see how autossh can help me with this.

    I did try to run:

    Code:
    ssh external ssh internal
    and I expected it to run just like

    Code:
    ssh external ls
    would do an ls on the external machine and then exit the ssh, but instead I received an error message:

    "Pseudo-terminal will not be allocated because stdin is not a terminal."

    Perhaps it was not meant to be : /

    EDIT: Oops, didn't see the image attached. Maybe this is possible! I just need to dive deeper into the abilities of autossh.

  6. #6
    Just Joined! dmk06's Avatar
    Join Date
    Jun 2010
    Location
    San Diego
    Posts
    37
    autossh just reestablishes an ssh connection like a profile or saving a putty session
    SSH Tunneling will forward the connection to the port on the local machine from a remote ip

    SSH: Tunneling Explained
    Last edited by dmk06; 06-11-2010 at 05:21 AM. Reason: adding

  7. #7
    Just Joined!
    Join Date
    May 2010
    Posts
    8
    Sorry for the slow reply; been without a computer for the weekend.
    I found an easy solution to the problem without using an extra program.

    ssh -t external ssh internal

    Can't believe I missed a builtin flag!

    Thanks for all your help though!

Posting Permissions

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