I am trying to clone to a gerrit server using another user username2 however it fails with Permission denied (publickey). I tried to generate an ssh key following the advice of Server Fault question "how do you create an ssh key for another user?"
The following steps didn't work. What am I missing?
ssh-keygen -f ~/.ssh/username2cp ~/.ssh/username2.pub ~/.ssh/authorized_keys- Added the username2.pub to tech-gerrit.sd.company.com
- ~/.ssh/config
Host tech-gerrit.sd.company.com HostName tech-gerrit.sd.company.com Port 29418 User username2 IdentityFile /Users/username1/.ssh/username2
- Tried to clone using below command
git clone ssh://[email protected]:29418
- Logged in as username2 into gerrit and added the username2.pub to
It would be better to list the exact commands you used so we could also look for typos and know which of the answers in question 323958 you followed. Also, it would be helpful to know about the software and configuration used on company.com.
Some things to try:
gitas the username. Perhaps company.com also does this. Try replacingusername2withgitin yourgit clonecommand.ssh-keygen -t rsa -f ~/.ssh/username2Hostline in ~/.ssh/config should match the name used on the command line, soHost tech-gerrit.sd.company.com- otherwise git and ssh won't use your entry in ~/.ssh/config at all.