plasticwrap.in 1.58 KB
Newer Older
1
2
3
4
5
6
7
#!/usr/bin/perl -w

#
# Configure variables
#
my $BOSSNODE = "@BOSSNODE@";
my $TBOPSEMAIL = "@TBOPSEMAIL@";
8
9

# Location of ssh program
10
11
12
13
14
if (-x "/usr/local/bin/ssh" ) {
	$ssh = "/usr/local/bin/ssh";
} elsif (-x "/usr/bin/ssh" ) {
	$ssh = "/usr/bin/ssh";
} else {
15
	die "Unable to find ssh - please send mail to $TBOPSEMAIL\n";
16
}
17
18

# Remote host to connect to
19
$host = $BOSSNODE;
20

21
22
# String to turn off password authentications
$nopass = "-o 'BatchMode yes'";
23

24
# Turn off host key checking.... for now.
25
$nokeycheck = "-o 'StrictHostKeyChecking no'";
26

27
28
29
# Make sure we use the right identity file
$identity = "-i $ENV{HOME}/.ssh/identity";

30
31
# Current working directory:
$cwd = $ENV{PWD};
32
33
# 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
34
if (!($cwd =~ qr|/users|) && !($cwd =~ qr|/proj|)) {
35
36
37
38
39
40
41
	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);
}

42
# Now, do the magic
43
44
45
46
$sshcmd = "$ssh $identity $nopass $nokeycheck $host 'cd $cwd \; $0 @ARGV'";
#print "About to run $sshcmd\n";
$rv = system $sshcmd;

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