how to generate an ssh key for another user?

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 ,following are the steps I followed which didnt work,what am I missing?

ssh-keygen -f username2
cp ~/.ssh/ ~/.ssh/authorized_keys
added the to

commans I used:

  Host tech-gerrit
  Port 29418
  User username2
  IdentityFile /Users/Documents/

Trying to clone using below command

git clone ssh://

1 answer

  • answered 2018-11-10 07:31 bitinerant

    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

    However, one thing that stood out as a potential problem: GitHub and GitLab are set up to use git as the username. Perhaps also does this. Try replacing username2 with git in your git clone command.