DEV Community

Khairun Nahar Nowrin
Khairun Nahar Nowrin

Posted on • Updated on

Generating a new SSH key and adding it to the ssh-agent in Mac

  1. Go to github profile
  2. Go to Profile settings

Image description

  1. Then click on SSH and GPG keys

Image description

  1. Open you mac terminal and Paste the text below, replacing the email used in the example with your GitHub email address
ssh-keygen -t ed25519 -C "your_email@example.com"

Enter fullscreen mode Exit fullscreen mode
  1. After Run the command it show

Image description
Put your laptop password

  1. After that it generate SHA256

Image description
7.Start the ssh-agent in the background.

$ eval "$(ssh-agent -s)"
> Agent pid 59566
Enter fullscreen mode Exit fullscreen mode
  1. Run
open ~/.ssh/config  
Enter fullscreen mode Exit fullscreen mode

If the file doesn't exist, create the file.

touch ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

Image description

  1. Open ~/.ssh/config file, then modify the file to contain the following lines. If your SSH key file has a different name or path than the example code, modify the filename or path to match your current setup.

Text

Host github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519 
Enter fullscreen mode Exit fullscreen mode

Image description

  1. Run
ssh-add --apple-use-keychain ~/.ssh/id_ed25519   
Enter fullscreen mode Exit fullscreen mode

If it show error like

Image description

Then run

ssh-keygen -t ed25519 -C Your_github_emailr@gmail.com
Enter fullscreen mode Exit fullscreen mode

Then run

Image description

  1. Go to your git hub account and click on "New SSH key"

Image description

  1. Provide title and key.

Image description

  1. For "key" open .ssh > id_ed25519.pub

Image description

Now clone a project from your github repository

git clone git@github.com:KhairunNaharNowrin/End-to-End-Testing-With-Cypress.git  
Enter fullscreen mode Exit fullscreen mode
  1. Setup the project environment
  2. Run
git add .  
Enter fullscreen mode Exit fullscreen mode
git commit -m "set up environment"
Enter fullscreen mode Exit fullscreen mode

It will show error like "Author identity unknown"

Run

git config --global user.email "you@example.com"
Enter fullscreen mode Exit fullscreen mode
  git config --global user.name "Your Name"
Enter fullscreen mode Exit fullscreen mode

to set your account's default identity.
Omit --global to set the identity only in this repository.

git push   
Enter fullscreen mode Exit fullscreen mode

Image description

reference -

Top comments (1)

Collapse
 
fireandsafetyjobs profile image
Fire and Safety Jobs

Very useful, thanks!