Generating a new SSH key

Share:

To generate a new SSH key and add it to the ssh-agent, follow these steps:

  1. Generate a new SSH key: Open your terminal or command prompt and enter the following command: cssCopyssh-keygen -t rsa -b 4096 -C "your_email@example.com" Replace "your_email@example.com" with the email address associated with your GitHub account. Press Enter to accept the default file location and optionally set a passphrase for added security.
  2. Start the ssh-agent (if not already running): If you are using a Linux or macOS system, you can start the ssh-agent by running the command: bashCopyeval "$(ssh-agent -s)" For Windows users, you can start the ssh-agent using: javascriptCopyeval `ssh-agent -s`
  3. Add your SSH private key to the ssh-agent: Use the command below to add your SSH private key to the ssh-agent: bashCopyssh-add ~/.ssh/id_rsa Replace id_rsa with the name of your private key file if it’s different.
  4. (Optional) Verify that the SSH key is added: You can verify that your SSH key is added to the ssh-agent by listing the keys using: csharpCopyssh-add -l
  5. Add the SSH key to your GitHub account: Copy the SSH public key to your clipboard using the command: bashCopypbcopy < ~/.ssh/id_rsa.pub For Windows users, you can use: bashCopyclip < ~/.ssh/id_rsa.pub Next, go to your GitHub account settings > SSH and GPG keys > New SSH key. Paste the copied SSH key into the “Key” field and give it a descriptive title. Click “Add SSH key” to save it.

Now, your new SSH key is generated, added to the ssh-agent, and linked to your GitHub account for authentication. You can use this SSH key to securely connect to GitHub repositories using Git and SSH.

Leave a Reply

Your email address will not be published. Required fields are marked *

LET’S KEEP IN TOUCH!

We’d love to keep you updated with our latest news and offers 😎

We don’t spam! Read our privacy policy for more info.

Contact Now