summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2012-03-01 00:53:55 +0000
committerJohn Southworth <john.southworth@vyatta.com>2012-03-01 00:53:55 +0000
commit18dc119573592a0c6fbf224c0b75c25b3c967af1 (patch)
tree67f17a0ecaa019fa8ec96f5ce0f44369123d1e73
parent368ab77a3ce670548d9fdfffb94594ca1e31ca9c (diff)
downloadvyatta-op-18dc119573592a0c6fbf224c0b75c25b3c967af1.tar.gz
vyatta-op-18dc119573592a0c6fbf224c0b75c25b3c967af1.zip
Bugfix 7555: Allow users to import ssh keys when using 'show tech-support save' commands
-rwxr-xr-xscripts/vyatta-remote-copy.pl22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/vyatta-remote-copy.pl b/scripts/vyatta-remote-copy.pl
index 78959ec..758c885 100755
--- a/scripts/vyatta-remote-copy.pl
+++ b/scripts/vyatta-remote-copy.pl
@@ -21,6 +21,7 @@
use strict;
use lib "/opt/vyatta/share/perl5";
+use IO::Prompt;
my $save_file;
@@ -61,6 +62,27 @@ if ($flag == 2)
if ($mode eq 'url') {
print "Saving output to $save_file\n";
my $rc = system("curl -# -T $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 $tmp_file $save_file");
+ print "\n";
+ }
+ }
system("rm -f $tmp_file");
if ($rc) {
print "Error saving $save_file\n";