I am setting up my ssh config for 2 different accounts in gitlab.
Host gitlab.com-roulette
HostName gitlab.com
User norayr.ghukasian
IdentityFile /home/norayr_ghukasyan/.ssh/id_ed25519_roulette
Host gitlab.com-devlix
HostName gitlab.com
User norayr.ghukasyan
IdentityFile /home/norayr_ghukasyan/.ssh/id_ed25519_devlix
I am getting a Permission denied
error. The strange thing for me is that the first one is working fine, therefore I think there is some tiny issue in my config that I am not aware of. I guess when the user or the server tries to connect, ssh automatically matches the first config with matched HostName
. How do I set up it properly to work for both of the accounts?
PS The User
s are different - norayr.ghukasian
and norayr.ghukasyan
.
Following Use difference accounts on a single GitLab instance you would setup your configuration like so:
Host norayr.ghukasian.gitlab.com
Hostname gitlab.com
PreferredAuthentications publickey
User git
IdentityFile /home/norayr_ghukasyan/.ssh/id_ed25519_roulette
Host norayr.ghukasyan.gitlab.com
Hostname gitlab.com
PreferredAuthentications publickey
User git
IdentityFile /home/norayr_ghukasyan/.ssh/id_ed25519_devlix
Then to clone a repo as norayr.ghukasian
user:
git clone git@norayr.ghukasian.gitlab.com:gitlab-org/gitlab.git
Using the username as the alias is not absolutely necessary. You can use a different alias if you wish and set it in the Host
section of your ssh config.
Key takeaways:
IdentityFile
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.