summaryrefslogtreecommitdiff
diff options
context:
space:
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;