#!/bin/bash echo "🔐 SSH Keypair Setup 🚀" echo "Enter your email: " read email echo "Enter your host name: " read hostname echo "Enter your user name (default git): " read username echo "Enter your key type (rsa, ed25519): " read keytype echo "Enter your key size (default 4096): " read keysize echo "Enter your key comment: " read keycomment echo "Enter your key passphrase (default empty): " read keypassphrase echo "Enter your key file name (default id_rsa): " read keyfilename echo "Enter your key file path (default ~/.ssh): " read keyfilepath echo "Enter your config file path (default ~/.ssh/config): " read configfilepath if [ -z "$username" ] then username="git" fi if [ -z "$keytype" ] then keytype="rsa" fi if [ -z "$keysize" ] then keysize=4096 fi if [ -z "$keypassphrase" ] then keypassphrase="" fi if [ -z "$keyfilename" ] then keyfilename="id_rsa" fi if [ -z "$keyfilepath" ] then keyfilepath="~/.ssh" fi if [ -z "$configfilepath" ] then configfilepath="~/.ssh/config" fi ssh-keygen -t "$keytype" -b "$keysize" -C "$keycomment" -f "$keyfilepath/$keyfilename" -N "$keypassphrase" touch "$configfilepath" if [ -z "$hostname" ] then echo "Host *" >> "$configfilepath" else echo "Host $hostname" >> "$configfilepath" fi echo " AddKeysToAgent yes" >> "$configfilepath" echo " IdentityFile $keyfilepath/$keyfilename" >> "$configfilepath" echo " User $username" >> "$configfilepath" echo "Your SSH Key Pair is created successfully! 🎉" echo "Your SSH Key Pair is located at $keyfilepath/$keyfilename" echo "Your SSH Config is located at $configfilepath" echo "Your SSH Public Key is copied to your clipboard" if [ -x "$(command -v pbcopy)" ] then pbcopy < "$keyfilepath/$keyfilename.pub" else cat "$keyfilepath/$keyfilename.pub" fi echo "Now you can add the public key to your server or services. Happy coding! 🚀"