diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-06 17:18:14 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-06 17:18:14 +0200 |
commit | 8d41c5cdb65031fe368144df2f40d20b8dc15c1b (patch) | |
tree | 142d7548f0c459ae4ce3ee94de337e17d1f61f23 | |
parent | True fix (diff) | |
download | joe-scripts-8d41c5cdb65031fe368144df2f40d20b8dc15c1b.tar.gz joe-scripts-8d41c5cdb65031fe368144df2f40d20b8dc15c1b.tar.bz2 joe-scripts-8d41c5cdb65031fe368144df2f40d20b8dc15c1b.tar.xz joe-scripts-8d41c5cdb65031fe368144df2f40d20b8dc15c1b.tar.zst joe-scripts-8d41c5cdb65031fe368144df2f40d20b8dc15c1b.zip |
Newuser update
-rwxr-xr-x | gitjoe-newuser.pl | 28 |
1 files 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'; ); } |