Example Use Case:
- Server: Digital Ocean
- Server Name: serverone
- First Gitlab Account Username: account1
- Second Gitlab Account Username: account2
Presumable you already have your first ssh key
~/.ssh/id_rsa
so we create a second ssh key
$ ssh-keygen -t rsa -C "root@serverone"
give the new key a different name
id_rsa_account2
So now we have 2 keys:
~/.ssh/id_rsa
~/.ssh/id_rsa_account2
$ cd ~/.ssh/
$ touch config
$ subl -a config
Then add
#account2 account
Host gitlab.com-account2
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_account2
copy paste your public ssh key from here
$ cat ~/.ssh/id_rsa_account2
and add it to gitlab ssh settings
In Laravel Forge, choose Custom when installing repository, and enter the path below
[email protected]:account2/awesomeproject.git
You're good to go!
If the repo exists under other company's account try:
git clone [email protected]:company/project.git