You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, there's no automated script or process for generating SSH keys and adding them to GitHub within the system-setup part of Linutil. This leaves users manually setting up SSH keys, which could be streamlined and standardized. For users who frequently need SSH keys for GitHub or other services, automating this process would save time and prevent potential setup errors.
I'd like to propose adding an automated script within the system-setup part of Linutil that generates SSH keys, prompts the user for details (like email and key type), optionally adds the key to the SSH agent, and copies the public key to the clipboard. After copying the key, the script can prompt the user to confirm if they've added it to GitHub and finally test the connection to GitHub.
Key features of the script:
Prompts for GitHub email and SSH key type (Ed25519 or RSA).
Allows a custom SSH key name or uses default.
Copies the generated public key to the clipboard using xclip.
Tests the SSH connection with GitHub.
This would simplify SSH key setup for users and fit well with the system-setup part of Linutil.
Alternatives include:
Keeping the process manual, which may continue to cause issues for users who are not familiar with the SSH setup.
Offering documentation for users to generate keys manually, but this would still leave them responsible for remembering and following multiple steps, which is prone to human error.
Here's a sample of how the script could look, which could be integrated into the system-setup section:
#!/bin/sh -e# Import common utilities. ./common-script.sh
# Function to prompt for GitHub configurationsetup_git_config() {
# Prompt for GitHub emailread -p "Enter your GitHub email address: " email
# Prompt for SSH key typeecho"Choose your SSH key type:"echo"1. Ed25519 (recommended)"echo"2. RSA (legacy)"read -p "Enter your choice (1 or 2): " key_type
# Set key algorithm based on user choicecase$key_typein
1) key_algo="ed25519" ;;
2) key_algo="rsa" ;;
*)
echo"Invalid choice. Exiting."exit 1
;;
esac# Prompt for custom key nameread -p "Enter a custom SSH key name (leave blank for default): " key_name
# Set the SSH key path based on user input
ssh_key_path="${HOME}/.ssh/${key_name:-id_$key_algo}"# Generate SSH key with specified type and email
ssh-keygen -t "$key_algo" -C "$email" -f "$ssh_key_path"# Prompt for passphrase usageread -p "Do you want to use a passphrase? (y/n): " use_passphrase
# If user opts for a passphrase, add key to SSH agentif [ "$use_passphrase"="y" ];then
ssh-add -l &>/dev/null ||eval"$(ssh-agent -s)"
ssh-add "$ssh_key_path"elseecho"Skipping passphrase setup."fiecho"SSH key generation and setup completed."
}
# Function to copy the SSH key to the clipboard and prompt user to add it to GitHubcopy_and_confirm_ssh_key() {
# Check if xclip is installed
checkCommandRequirements "xclip"# Copy the generated public key to the clipboard using xclip
cat "${ssh_key_path}.pub"| xclip -selection clipboard
echo"Your SSH public key has been copied to the clipboard."# Prompt user to confirm they've added the key to GitHubwhiletrue;doread -p "Have you pasted your SSH public key into your GitHub account? (y/n): " yn
case$ynin
[Yy]* ) echo"Proceeding...";break ;;
[Nn]* ) echo"Please paste your SSH public key into GitHub and try again.";exit ;;
* ) echo"Please answer yes (y) or no (n)." ;;
esacdone# Test the SSH connection with GitHub
ssh -T [email protected]
}
# Check environment and necessary tools
checkEnv
# Main execution
setup_git_config
copy_and_confirm_ssh_key
By automating this, the script will enhance usability and reduce setup errors.
The text was updated successfully, but these errors were encountered:
Currently, there's no automated script or process for generating SSH keys and adding them to GitHub within the
system-setup
part of Linutil. This leaves users manually setting up SSH keys, which could be streamlined and standardized. For users who frequently need SSH keys for GitHub or other services, automating this process would save time and prevent potential setup errors.I'd like to propose adding an automated script within the
system-setup
part of Linutil that generates SSH keys, prompts the user for details (like email and key type), optionally adds the key to the SSH agent, and copies the public key to the clipboard. After copying the key, the script can prompt the user to confirm if they've added it to GitHub and finally test the connection to GitHub.Key features of the script:
xclip
.This would simplify SSH key setup for users and fit well with the
system-setup
part of Linutil.Alternatives include:
Here's a sample of how the script could look, which could be integrated into the
system-setup
section:By automating this, the script will enhance usability and reduce setup errors.
The text was updated successfully, but these errors were encountered: