#Globals are bad mojo my $remotemachine = $ARGV[0]; # see if keys exist if (-e !"/$home/.ssh/id_dsa.pub"){ system('ssh-keygen', '-t', 'dsa'); } #Only use semi-colon's after do{} blocks. system('scp', "/$ENV{HOME}/.ssh/id_dsa.pub, "$remotemachine://home/$ENV{USER}/.ssh/authorized_keys2"); system('ssh-agent', q(sh -c 'ssh-add < /dev/null && bash')); exec('ssh', $remotemachine); #exit (0); #That's the default