This project is maintained by mantejjosan
Setting up an SSH key for Git is a straightforward process.
First, check if you already have an SSH key on your system:
ls -al ~/.ssh
If you see files like id_rsa
and id_rsa.pub
, you already have an SSH key. You can skip to Step 3. Otherwise, proceed to Step 2.
If you don’t have an SSH key or want to create a new one, follow these steps:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Replace "your_email@example.com"
with your email address.
Enter file in which to save the key (/home/your_user/.ssh/id_rsa): [Press Enter]
Press Enter
to accept the default location.
Enter passphrase (empty for no passphrase): [Your Passphrase]
Enter same passphrase again: [Repeat Your Passphrase]
A passphrase adds an extra layer of security, but you can leave it empty if you prefer.
To ensure the SSH key is used automatically, add it to the SSH agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
If your key has a different name, replace id_rsa
with your key’s name.
Now, you need to add your SSH key to your GitHub (or equivalent Git service) account.
cat ~/.ssh/id_rsa.pub
Copy the entire output, which is your SSH public key.
Verify that your SSH key is correctly set up and that you can connect to GitHub:
ssh -T git@github.com
If everything is set up correctly, you should see a message like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Now that your SSH key is set up, you can push your changes:
git remote -v
If the URL starts with https://
, update it to SSH:
git remote set-url origin git@github.com:username/repo.git
Replace username
with your GitHub username and repo
with your repository name.
git push -u origin main
This should work without asking for a username or password since you’re using SSH. If you encounter any issues or error messages during this process, let me know!