#!/usr/bin/perl -w # This is a ssh replacement script to access machine behind another one # directly. Store in your path as ssh to use it. # # Have a look at the Translate section below to make it work for your # configuration. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # Author: Nicolas Schodet # use strict; my $ssh = '/usr/bin/ssh'; my ($login, $host, @args); # Parse the arguments. while ($_ = shift) { # Get login. if (/^-l$/) { $login = shift } elsif (/^-l/) { $login = substr $_, 2 } # Get host or stop. elsif (!/^-/) { if ($host) { unshift @ARGV, $_; last } else { $host = $_; } } # Get options. else { push @args, $_ } } # Decode host. unless ($host) { exec $ssh } if ($host =~ /(.*)@(.*)/) { $login = $1; $host = $2; } # Get command. my $cmd; if (@ARGV) { $cmd = join ' ', @ARGV; } # Translate. for ($host) { if (/^noe(.linux.efrei.fr)?$/) { $host = "choam.efrei.fr"; $cmd = 'ssh noe.linux.efrei.fr' . ($cmd ? ' ' . $cmd : ''); } if (/^robot(.assos.efrei.fr)?$/) { $host = "choam.efrei.fr"; $cmd = 'ssh robot.assos.efrei.fr' . ($cmd ? ' ' . $cmd : ''); } } # Fill args. push @args, '-l' . $login if $login; push @args, $host; push @args, $cmd if $cmd; # This is for debug. #open TTY, ">/dev/tty"; #print TTY join ':', @args, "\n"; #close TTY; exec $ssh, @args;