plasticwrap 1.52 KB
Newer Older
1 2 3
#!/usr/bin/perl

# Location of ssh program
4 5 6 7 8 9 10
if (-x "/usr/local/bin/ssh" ) {
	$ssh = "/usr/local/bin/ssh";
} elsif (-x "/usr/bin/ssh" ) {
	$ssh = "/usr/bin/ssh";
} else {
	die "Unable to find ssh - please send mail to testbed-ops\@fast.cs.utah.edu\n";
}
11 12

# Remote host to connect to
13
$host = "boss.emulab.net";
14

15 16
# String to turn off password authentications
$nopass = "-o 'BatchMode yes'";
17

18
# Turn off host key checking.... for now.
19
$nokeycheck = "-o 'StrictHostKeyChecking no'";
20

21 22 23
# Make sure we use the right identity file
$identity = "-i $ENV{HOME}/.ssh/identity";

24 25
# Current working directory:
$cwd = $ENV{PWD};
26 27
# We only want to actually change to $CWD if it will actually
# be accesible on the other machine - if it's in /users or /proj
28
if (!($cwd =~ qr|/users|) && !($cwd =~ qr|/proj|)) {
29 30 31 32 33 34 35
	warn "In order to make sure that this command has access to any\n";
	warn "files it may need to read, please change directories into\n";
	warn "your home directory (in /users/) or your project directory\n";
	warn "(in /proj/).\n";
	exit (-1);
}

36
# Now, do the magic
37 38 39 40
$sshcmd = "$ssh $identity $nopass $nokeycheck $host 'cd $cwd \; $0 @ARGV'";
#print "About to run $sshcmd\n";
$rv = system $sshcmd;

41
if ($rv > 256) {
42 43 44
	print "**********\n";
	print "SSH failed. You may need to run the following commands:\n\n";
	print "mkdir -m 0755 $ENV{HOME}/.ssh\n";
45 46
	print "ssh-keygen -P '' -f $ENV{HOME}/.ssh/identity\n";
	print "cp $ENV{HOME}/.ssh/identity.pub $ENV{HOME}/.ssh/authorized_keys\n";
47 48
	print "chmod 600 $ENV{HOME}/.ssh/authorized_keys\n";
	print "**********\n";
49
}