Last active
July 28, 2019 19:13
Revisions
-
Joker-vD revised this gist
Jul 28, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,8 @@ test -n "$NEW_USERNAME" command -v sudo >/dev/null test -x /bin/bash adduser --shell=/bin/bash -- "$NEW_USERNAME" adduser -- "$NEW_USERNAME" sudo NEW_HOMEDIR="$( getent -- passwd "$NEW_USERNAME" | cut -d: -f6 )" test -n "$NEW_HOMEDIR" -
Joker-vD created this gist
Jul 28, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/sh -e NEW_USERNAME=joker test -n "$NEW_USERNAME" command -v sudo >/dev/null test -x /bin/bash adduser --shell=/bin/bash "$NEW_USERNAME" adduser "$NEW_USERNAME" sudo NEW_HOMEDIR="$( getent -- passwd "$NEW_USERNAME" | cut -d: -f6 )" test -n "$NEW_HOMEDIR" cd -- "$NEW_HOMEDIR" chown_and_mod() { chown -- "$NEW_USERNAME:$NEW_USERNAME" "$2" chmod -- "$1" "$2" } NEW_SSHDIR="$NEW_HOMEDIR/.ssh" mkdir -- "$NEW_SSHDIR" chown_and_mod 700 "$NEW_SSHDIR" NEW_AUTHKEYS_FILE="$NEW_SSHDIR/authorized_keys" IFS= read -p 'Enter a new entry for authorized_keys file: ' PUBKEY_LINE printf '%s\n' "$PUBKEY_LINE" >> "$NEW_AUTHKEYS_FILE" chown_and_mod 600 "$NEW_AUTHKEYS_FILE"