Permalink
Browse files

Fixed "command" from other authkeys breaking authkeys file parsing

The regexp will remove command or other options at the start of each
lines from the authkeys file. The remaining part of the line should be
the public key only without any other ssh options.

Note that it will only detect on authorized_keys file for protocol 2
(but who use protocol 1 anymore?)
  • Loading branch information...
1 parent 089f0f9 commit 233d2d4ba9755c7ad41d402bef1316e7a9666f3c @Wizmaster Wizmaster committed Jan 8, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/triggers/post-compile/ssh-authkeys
@@ -121,7 +121,12 @@ sub fp_file {
sub fp_line {
my ( $fh, $fn ) = tempfile();
- print $fh shift;
+
+ my $authkey = shift;
+ # Remove potential command prefix and options from authkeys file
+ $authkey =~ s/^.* ((?:ssh-rsa|ssh-dss|ecdsa-\S+) .*$)/$1/gm;
+
+ print $fh $authkey;
close $fh;
my $fp = fp_file($fn);
unlink $fn;

0 comments on commit 233d2d4

Please sign in to comment.