summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/vyatta-save-config.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl
index 00f5854..913a44c 100755
--- a/scripts/vyatta-save-config.pl
+++ b/scripts/vyatta-save-config.pl
@@ -23,6 +23,8 @@ use strict;
use lib "/opt/vyatta/share/perl5";
use Vyatta::ConfigOutput;
use File::Sync qw(fsync);
+use FileHandle;
+use IO::Prompt;
use Vyatta::Misc qw(get_short_config_path);
my $etcdir = "/opt/vyatta/etc";
@@ -120,6 +122,27 @@ close $save;
if ($mode eq 'url') {
my $rc = system("curl -# -T $url_tmp_file $save_file");
+ if ($proto eq 'scp' && ($rc >> 8) == 51){
+ $save_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 $save_file");
+ print "\n";
+ }
+ }
system("rm -f $url_tmp_file");
if ($rc) {
print "Error saving $save_file\n";