my computer -> home computer -> work server via ssh - SSH

This is a discussion on my computer -> home computer -> work server via ssh - SSH ; Hello, When working from home or the office, I copy files to and from my dev server using ssh. My coworker who maintains the server added my home ip address so that I can access the the files from there ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: my computer -> home computer -> work server via ssh

  1. my computer -> home computer -> work server via ssh

    Hello,
    When working from home or the office, I copy files to and from my dev
    server using ssh. My coworker who maintains the server added my home
    ip address so that I can access the the files from there as well. As I
    move around a lot, my coworker must be growing tired of me constantly
    requesting additional IPs.

    I figured out how to ssh to my home linux, then ssh to my dev server.
    However, I have to do twice the work to get a file on my on-the-go
    machine to play with. Is there a way I can forward, bounce, or somehow
    shorten the process of getting files from work server <-> home
    computer <-> my laptop ?

    Thanks for the ideas.


  2. Re: my computer -> home computer -> work server via ssh

    On Sun, 23 Sep 2007 20:47:06 -0000, Ultrus wrote:
    > Hello,
    > When working from home or the office, I copy files to and from my dev
    > server using ssh. My coworker who maintains the server added my home
    > ip address so that I can access the the files from there as well. As I
    > move around a lot, my coworker must be growing tired of me constantly
    > requesting additional IPs.
    >
    > I figured out how to ssh to my home linux, then ssh to my dev server.
    > However, I have to do twice the work to get a file on my on-the-go
    > machine to play with. Is there a way I can forward, bounce, or somehow
    > shorten the process of getting files from work server <-> home
    > computer <-> my laptop ?
    >
    > Thanks for the ideas.
    >


    It is called port forwarding and works very well.

    Here's my forward-port.pl perl script, that maintains active port
    forwardings despite extremely adverse conditions (such as forced
    disconnects, network down often, cannot forward local port bug in ssh,
    change of IPs, etc).

    I use it on my laptop.

    To make it work, the process on the other end should output something
    more often than the sleep period specified in the script
    arguments. This output is used as a heartbeat.

    i
    #!/usr/bin/perl

    use strict;
    use warnings;

    use Getopt::Long;

    my $rhost = 'manifold';
    my $lhost = 'localhost';

    # security implications. Be careful on public networks!
    my $local_interface = 'localhost';
    my $remote_interface = 'localhost';

    my $lport = undef;
    my $rport = undef;

    my $sleep = 10;
    my $once = undef;
    my $back = undef;
    my $login = undef;

    my $alarm = undef;

    GetOptions(
    "rhost=s" => \$rhost,
    "lhost=s" => \$lhost,
    "local_interface=s" => \$local_interface,
    "remote_interface=s" => \$remote_interface,
    "lport=i" => \$lport,
    "rport=i" => \$rport,
    "sleep=i" => \$sleep,
    "once" => \$once,
    "back" => \$back,
    "login=s" => \$login,
    "alarm=i" => \$alarm,
    );

    my $remote_command = join( ' ', @ARGV );

    die "Cannot figure out local port (either --lport argument or just an argument"
    unless defined $lport;

    $rport = $lport unless defined $rport;

    $| = 1;

    do {
    my $cmd = "ssh -n ";
    $cmd .= ' -N ' unless $remote_command;

    $cmd .= "-l $login " if defined $login;

    if( $back ) {
    $cmd .= "-R $remote_interface:$rport:$local_interface:$lport ";
    } else {
    $cmd .= "-L $local_interface:$lport:$remote_interface:$rport ";
    }

    $cmd .= "$rhost ";

    $cmd .= $remote_command;

    my $date = `date`; chomp $date;


    open( SSH, "$cmd < /dev/null 2>&1 |" ) || die "Cannot start SSH";

    print "CMD=$cmd!!! date is $date\n";

    my $run = 1;

    do {

    my $line = "";
    if( $alarm ) {
    eval {
    local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
    alarm $alarm;
    $line = ;
    alarm 0;
    };
    if( $@ ) {
    close( SSH );
    print "Timed out on ssh connection at " . `date`;
    sleep 2;
    $run = 0;
    }
    } else {
    $line = ;
    }

    if( $line ) {

    print $line;
    if( $line =~ /Warning: remote port forwarding failed/ ) {
    print "Failed to forward port -- closing.\n";
    close( SSH );
    $run = 0;
    }
    } else {
    $run = 0;
    }
    } while( $run );
    close( SSH );
    if( $? ) {
    print "SSH somehow failed.\n";
    }
    last if $once;

    print "Retrying in $sleep seconds...\n";

    sleep $sleep if $sleep;
    } while( 1 );

  3. Re: my computer -> home computer -> work server via ssh

    On Sun, 23 Sep 2007 20:47:06 +0000, Ultrus wrote:
    > I figured out how to ssh to my home linux, then ssh to my dev server.
    > However, I have to do twice the work to get a file on my on-the-go
    > machine to play with. Is there a way I can forward, bounce, or somehow
    > shorten the process of getting files from work server <-> home
    > computer <-> my laptop ?


    Add a line in your ~/.ssh/config file on your laptop (or add the
    equivalent command to PuTTY using plink, see the PuTTY docs):

    Host work.somewhere.net
    ProxyCommand=ssh -qax home.elsewhere.net nc %h %p

    Then you can ssh (or scp etc) to work but the connection will be
    forwarded through your home box. The encrypted ssh connection is carried
    over a lightweight netcat. No need to double encrypt.

  4. Re: my computer -> home computer -> work server via ssh

    On 2007-09-23, Ultrus wrote:

    > When working from home or the office, I copy files to and from my dev
    > server using ssh. My coworker who maintains the server added my home
    > ip address so that I can access the the files from there as well. As I
    > move around a lot, my coworker must be growing tired of me constantly
    > requesting additional IPs.
    >
    > I figured out how to ssh to my home linux, then ssh to my dev server.
    > However, I have to do twice the work to get a file on my on-the-go
    > machine to play with. Is there a way I can forward, bounce, or somehow
    > shorten the process of getting files from work server <-> home
    > computer <-> my laptop ?


    I asked a similar question in June and got this useful answer:

    http://groups.google.com/group/comp....c1f74557e119dc
    Message-ID:

+ Reply to Thread