summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2012-03-01 00:43:59 +0000
committerJohn Southworth <john.southworth@vyatta.com>2012-03-01 00:43:59 +0000
commit59fef0e559861380e40933406b86812f3e22d7b1 (patch)
tree1d5634c2280e6518e367b6d1eba929a91ffc630f
parent9927e7efb9d01b2f2bc237171d3454720c44d337 (diff)
downloadvyatta-cfg-system-59fef0e559861380e40933406b86812f3e22d7b1.tar.gz
vyatta-cfg-system-59fef0e559861380e40933406b86812f3e22d7b1.zip
Bugfix 7555: Allow users to import keys when using loadkey
-rwxr-xr-xscripts/vyatta-load-user-key.pl26
1 files changed, 25 insertions, 1 deletions
diff --git a/scripts/vyatta-load-user-key.pl b/scripts/vyatta-load-user-key.pl
index d64dba8a..4e0c84e2 100755
--- a/scripts/vyatta-load-user-key.pl
+++ b/scripts/vyatta-load-user-key.pl
@@ -71,7 +71,30 @@ sub geturl {
}
$cmd .= " $url";
- open (my $curl, "-|", $cmd )
+ my $curl_out = `$cmd`;
+ my $rc = ($? >> 8);
+ if ($proto eq 'scp' && $rc == 51){
+ $url =~ m/scp:\/\/(.*?)\//;
+ my $host = $1;
+ if ($host =~ m/.*@(.*)/) {
+ $host = $1;
+ }
+ my $rsa_key = `ssh-keyscan -t rsa $host 2>/dev/null`;
+ print "The authenticity of host '$host' can't be established.\n";
+ my $fingerprint = `ssh-keygen -lf /dev/stdin <<< \"$rsa_key\" | awk {' print \$2 '}`;
+ chomp $fingerprint;
+ print "RSA key fingerprint is $fingerprint.\n";
+ if (prompt("Are you sure you want to continue connecting (yes/no) [Yes]? ", -tynd=>"y")) {
+ mkdir "~/.ssh/";
+ open(my $known_hosts, ">>", "$ENV{HOME}/.ssh/known_hosts")
+ or die "Cannot open known_hosts: $!";
+ print $known_hosts "$rsa_key\n";
+ close($known_hosts);
+ $curl_out = `curl -# $url`;
+ print "\n";
+ }
+ }
+ open (my $curl, "<", \$curl_out)
or die "$cmd command failed: $!";
return $curl;
@@ -80,6 +103,7 @@ sub geturl {
sub getkeys {
my ($user, $in) = @_;
+ print "\n";
while (<$in>) {
chomp;