summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2012-03-01 00:00:52 +0000
committerJohn Southworth <john.southworth@vyatta.com>2012-03-01 00:00:52 +0000
commitb18bbaf1898fa25f87efca7e9ae68fc5057d1998 (patch)
tree788572f6d182eb2d127ef833772149832c28f78d
parentab725a781134de29ff7ec668ab4b608ae3f31bfb (diff)
downloadvyatta-cfg-b18bbaf1898fa25f87efca7e9ae68fc5057d1998.tar.gz
vyatta-cfg-b18bbaf1898fa25f87efca7e9ae68fc5057d1998.zip
Bugfix 7555: Allow users to import keys when using the 'load' command from config mode
-rwxr-xr-xscripts/vyatta-load-config.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl
index 7bf7779..dc9ad6e 100755
--- a/scripts/vyatta-load-config.pl
+++ b/scripts/vyatta-load-config.pl
@@ -127,6 +127,27 @@ elsif ( $mode eq 'url' ) {
}
}
my $rc = system("curl -# -o $url_tmp_file $load_file");
+ if ($proto eq 'scp' && ($rc >> 8) == 51){
+ $load_file =~ 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);
+ $rc = system("curl -# -o $url_tmp_file $load_file");
+ print "\n";
+ }
+ }
if ($rc) {
print "Can not open remote configuration file $load_file\n";
exit 1;