I have followed the tutorial to set SSH key for multiple github accounts.
But I keep getting the error
ssh: Could not resolve hostname github-psdtowordpresspro.com: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Steps followed:
- Created SSH key:
id_rsa_psdtowordpresspro.pub
file in.ssh
directory. (Note that this folder was not there earlier. so I had to create one)
Used the syntax ssh-keygen -t rsa -C "your-email-address"
Added the SSH key to my 2nd github account
Added the key
ssh-add ~/.ssh/id_rsa_COMPANY
Created the
.config
file with the commandtouch ~/.ssh/config vim config
This is the code I wrote in my .config
file
Host github-regipheirim
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_psdtowordpresspro
which is exactly how it was mentioned in the tutorial.
Then I added the remote origin as
git remote add origin git@github-psdtowordpresspro.com:regipheirim/regi.git
But then when I try to push it shows the error that "Hostname could not be resolved."
Here is a screenshot of
Git remote connection setting of second account
Project's .config
file
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = git@github-regipheirim:regipheirim/regi.git
fetch = +refs/heads/*:refs/remotes/origin/*
[user]
name = regipheirim
email = p.regidev@gmail.com
ALSO TRIED (Based on suggestion from TJL in comment section)
git remote set-url origin git@github.com:regipheirim/regi.git
But then when I tried to push with
git push origin master
Again I get the error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So can anyone help me with what I am doing wrong here. I just spent the entire sunday figuring it out.