From 8d41c5cdb65031fe368144df2f40d20b8dc15c1b Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 6 Jul 2020 17:18:14 +0200 Subject: Newuser update --- gitjoe-newuser.pl | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/gitjoe-newuser.pl b/gitjoe-newuser.pl index 7995668..5da9c2b 100755 --- a/gitjoe-newuser.pl +++ b/gitjoe-newuser.pl @@ -15,6 +15,7 @@ sub main { } my $usr = $ARGV[0]; my $pass = $ARGV[1]; + my $sshkey = $ARGV[2]; my $home_dir = '/usr/home/' . $usr . '/'; system( '/usr/local/bin/dash', @@ -39,20 +40,33 @@ yes no EOF" ); -# my $gitshell_cmds = "cd -# touch -# git -# ls"; - system( '/usr/local/bin/dash', '-c', - '/bin/mkdir -v ' . $home_dir . 'git-shell-commands' + '/bin/mkdir -v ' . $home_dir . '.ssh'; + ); + system( + '/usr/local/bin/dash', + '-c', + '/bin/chown -v ' . $usr . ':' . $usr . ' ' . $home_dir . '.ssh'; + ); + system( + '/usr/local/bin/dash', + '-c', + '/bin/chmod -v 700 ' . $home_dir . '.ssh/'; + ); + open(my $fh, '>:encoding(UTF-8)', $home_dir . '.ssh/authorized_keys'); + print $fh $sshkey; + close($fh); + system( + '/usr/local/bin/dash', + '-c', + '/bin/chown -v ' . $usr . ':' . $usr . ' ' . $home_dir . '.ssh/authorized_keys'; ); system( '/usr/local/bin/dash', '-c', - '/bin/ln -v -s /bin/ls ' . $home_dir . 'git-shell-commands/ls' + '/bin/chmod -v 600 ' . $home_dir . '.ssh/authorized_keys'; ); } -- cgit v1.2.3