Hi all,
If you specify this perl script as a ForceCommand, users will not be able to run
commands (or scp) remotely, only login.
Probably no-one will have a use for this but I thought I'd share because it
shows how to run a shell as a login shell from a ForceCommand.
Wout.
#!/usr/bin/perl
use strict;
# Give the user a shell if that was their intention
if (exists $ENV{SSH_TTY} && not exists $ENV{SSH_ORIGINAL_COMMAND}) {
# Find out what their shell is
my @pw = getpwuid($<);
my $shell = $pw[8] || '/bin/sh';
# Run it as a login shell
exec { $shell } '-sh' ;
} else {
print STDERR "Remote commands disabled, please login
instead.\n";
}