Commit 649a30ac authored by David Johnson's avatar David Johnson

Add a method that explicitly returns *only* Emulab-generated pubkeys.

This method looks to see if these keys were *likely* generated by us.
The regular GetSSHKeys specifically filters these out.  This new method
should be used carefully, since these keys are not passphrase-protected.
For instance, I'm only using it for loading keys on switches that are
only locally accessible right now.
parent 74acd9e3
......@@ -1076,6 +1076,41 @@ sub GetSSHKeys($$)
return 0;
# Get (hopefully) unencrypted, locally-generated user ssh keys. This is
# bogus; I am making sure to only return locally-generated keys.
sub GetDefaultSSHKeys($$;$)
my ($self, $pref, $onlylatest) = @_;
my @result = ();
# Must be a real reference.
return -1
if (! (ref($self) && ref($pref)));
my $uid_idx = $self->uid_idx();
my $extra = '';
if (defined($onlylatest) && $onlylatest) {
$extra = 'order by stamp desc limit 1';
my $query_result =
DBQueryWarn("select pubkey from user_pubkeys ".
"where uid_idx='$uid_idx' and ".
" comment like '%\@${OURDOMAIN}' $extra");
return -1
if (!defined($query_result));
while (my ($key) = $query_result->fetchrow_array()) {
push(@result, $key);
@$pref = @result;
return 0;
# Get the passphrase for the encrypted key.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment