Enable passwordless sudo if user password not set#106
Merged
Conversation
Owner
|
Appreciate this but I my concern would be that silently adding Maybe a middleground could be that we have option to add a random password or user can explicitly choose to have no password and gets a warning message... I am thinking somehthing like: if [[ -z "$PASS1" && -z "$PASS2" ]]; then
print_warning "Password skipped. Relying on SSH key authentication."
print_warning "Without a password, you will NOT be able to use 'sudo' for administrative tasks."
if confirm "Generate a secure random password for you? (Recommended)" "y"; then
local RAND_PASS
RAND_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24)
if echo "$USERNAME:$RAND_PASS" | chpasswd >/dev/null 2>&1; then
print_success "Generated random password for '$USERNAME'."
printf '\n%s\n' "${YELLOW}⚠ SAVE THIS PASSWORD FOR SUDO ACCESS:${NC}"
printf ' %s\n\n' "${BOLD}$RAND_PASS${NC}"
log "Generated random password for '$USERNAME'."
break
else
print_error "Failed to set random password."
fi
elif confirm "Enable passwordless sudo? (WARNING: Security Risk)" "n"; then
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/$USERNAME"
chmod 0440 "/etc/sudoers.d/$USERNAME"
print_warning "Passwordless sudo enabled for '$USERNAME'."
log "Passwordless sudo explicitly enabled for '$USERNAME'."
break
else
print_warning "No password set and passwordless sudo disabled. You will not have admin rights."
log "Password setting skipped, no sudo rights for '$USERNAME'."
break
fi
elif [[ "$PASS1" == "$PASS2" ]]; thenWhat you think would this work? |
Contributor
Author
|
Sorry I saw this late. I quickly fixed it when I saw for my own system and created a PR without thinking of other cases. I agree with the changes you made - I would have done the same. Thanks for your response! |
This file contains hidden or 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 characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.