====== Using SSH Keys with GitHub ====== ==== Why Use SSH Keys? ==== * **Security:** SSH keys provide a more secure way to authenticate with GitHub compared to using passwords. * **Convenience:** Once set up, you don't need to enter your password for every Git operation. ==== Generating an SSH Key ==== 1. Open your terminal. 2. Generate a new SSH key pair: ssh-keygen -t ed25519 -C "your_email@example.com" Replace `your_email@example.com` with your actual email address. You'll be prompted to enter a file location (default is `~/.ssh/id_ed25519`) and a passphrase. It's recommended to use a passphrase for added security. 3. Locate the public key: The public key is located in `~/.ssh/id_ed25519.pub`. ==== Adding the Public Key to GitHub ==== - Log in to GitHub. - Go to your account settings. - Navigate to the "SSH and GPG keys" section. - Click "New SSH key." - Give the key a title (e.g., "Your computer") and paste the contents of your public key into the key text area. - Click "Add SSH key." ==== Testing the SSH Connection ==== - Open your terminal. - Run the following command: ssh -T git@github.com If successful, you should see a welcome message from GitHub. ==== Using SSH with Git ==== To clone a repository using SSH: git clone git@github.com:username/repository_name.git Replace `username` and `repository_name` with your actual GitHub username and repository name. ==== Additional Tips ==== * **SSH agent:** Use `ssh-agent` to manage your SSH keys and avoid entering the passphrase repeatedly. * **Multiple SSH keys:** If you have multiple computers or want to use different keys for different purposes, you can generate multiple key pairs and add them to GitHub. * **SSH config:** You can configure SSH settings in the `~/.ssh/config` file to simplify the connection process. * **Key revocation:** If your SSH key is compromised, you can revoke it on GitHub. **By following these steps, you'll have a secure and efficient way to interact with GitHub.**