Sometimes you will need to deal with multiple projects at the same time, some client with AWS, Gitlab, Github etc.
Here are some steps that could be helpful ;)
1. Create a new SSH Key
ED25519
ssh-keygen -t ed25519 -C "<comment>"
RSA 2048
ssh-keygen -t rsa -b 2048 -C "<comment>"
2. Add SSH Key
eval $(ssh-agent -s)
ssh-add <directory to private SSH key>
3. Setup config
Touch or update the config
file in ~/.ssh/
:
Host gitlab-scope
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_com_rsa
AWS Codecommit
Host aws-codecommit
HostName git-codecommit.{region}.amazonaws.com
User APKARF3PHVLQ1EXAMPLE
PreferredAuthentications publickey
IdentityFile ~/.ssh/private_key
PubkeyAcceptedAlgorithms +ssh-rsa
HostkeyAlgorithms +ssh-rsa
Hostnames
- Gitlab:
gitlab.com
- Github:
github.com
- AWS Codecommit:
git-codecommit.{region}.amazonaws.com
4. Setup public key
cat private_key.pub
ssh-ed25519 ABBBC3NzaC1lZDI1NTE5AAAAIBSFa3klpakF4ZkNPO7JWMsQDqy3Wd6ZvyPslt <comment>
Copy the key to your repository preferences and create the SSH key
5. Verify the connection
ssh -T git@gitlab-scope
The authenticity of host 'gitlab.com (172.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:hfksfbdfoerHKSDKFDFDFDF.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitlab.com,172.0.0.1' (ECDSA) to the list of known hosts.
Welcome to GitLab, @user!
6. Clone the repository
git clone git@gitlab-scope:project/repository-name.git
AWS Codecommit
git clone ssh://aws-codecommit/v1/repos/repository-name
Top comments (0)