mirror of
https://github.com/darksaid98/ubuntu-server-setup.git
synced 2026-12-02 14:38:58 +00:00
Enables one to run setup without creating a new user by using a second non-root account (#15)
* Enable one to choose to use an existing second non-root account for configuring the server. * Current user by def * Changed default TimeZone and added a more secure ssh key derivation method according to https://blog.peterruppel.de/ed25519-for-ssh/ * Refactor setup scripts Co-authored-by: BreakSecurity <[email protected]>
This commit is contained in:
1 parent
8c4f801e10
commit
7beaeed0cd
3 files changed
+29
-8
No files matched your search
@@ -18,18 +18,29 @@ includeDependencies
|
||||
output_file="output.log"
|
||||
|
||||
function main() {
|
||||
read -rp "Enter the username of the new user account:" username
|
||||
read -rp "Do you want to create a new non-root user? (Recommended) [Y/N] " createUser
|
||||
|
||||
# Run setup functions
|
||||
trap cleanup EXIT SIGHUP SIGINT SIGTERM
|
||||
|
||||
addUserAccount "${username}"
|
||||
if [[ $createUser == [nN] ]]; then
|
||||
username=$(whoami)
|
||||
updateUserAccount "${username}"
|
||||
elif [[ $createUser == [yY] ]]; then
|
||||
read -rp "Enter the username of the new user account: " username
|
||||
addUserAccount "${username}"
|
||||
else
|
||||
echo 'This is not a valid choice!'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -rp $'Paste in the public SSH key for the new user:\n' sshKey
|
||||
echo 'Running setup script...'
|
||||
logTimestamp "${output_file}"
|
||||
|
||||
exec 3>&1 >>"${output_file}" 2>&1
|
||||
|
||||
|
||||
disableSudoPassword "${username}"
|
||||
addSSHKey "${username}" "${sshKey}"
|
||||
changeSSHConfig
|
||||
@@ -87,4 +98,4 @@ function setupTimezone() {
|
||||
echo "Timezone is set to $(cat /etc/timezone)" >&3
|
||||
}
|
||||
|
||||
main
|
||||
main
|
||||
Reference in new issue
Block a user