Authorized Key Commands

Please be sure to have read and understood public key authentication. In ~/.ssh/authorized_keys a public key may be prepended by comma-separated list of options:

Executing SOFT_CMD although HARD_CMD is specified:

Example script:

#!/usr/bin/perl

use strict;
use warnings;

my ($remote_ip, $remote_port, $local_port) = split(' ', $ENV{'SSH_CLIENT'});
my $command = $ENV{'SSH_ORIGINAL_COMMAND'};

my $oh_yeah = 0;
if ($remote_ip =~ m/^XXX.YYY./) {
    if ($command eq 'SOFT_CMD') {
        $oh_yeah = 1;
    }
}

if ($oh_yeah) {
    system($command);
}
Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.