Swipe left or right to navigate to next or previous post
This blog post is about how to access the GitHub account using the SSH. The tutorial uses the ubuntu server and GitHub. However, steps are pretty much similar with other Operating systems and source code management tool
SSH (Secure Shell) is secure cryptographic network protocol which is used to securely connect to the remote server. By using SSH, data can be transmitted to the remote server and download the data from the remote server.
SSH provides the secure encryption and verification to secure communication. It is based on client server model.
Follow the Generate multiple SSH Keys for different GitHub accounts post to create generate multiple ssh for multiple GitHub accounts
eval `ssh-agent -s` ssh-add
ssh-add -D
ssh-add ~/.ssh/id_rsa_personal ssh-add ~/.ssh/id_rsa_office
Append the following content located in ~/.ssh/config file. If the file is not available, create a new file.
Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_personal Host github.com-personal HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
You will have the SSH repo url in following format for GitHub repo
[email protected]:username/awesome-project.git
Update the github.com with the Host like github.com-office for the repo that belongs to the office repo and github.com-personal for the repo belongs to the personal repo.
Final repo url for personal Repo will be like:
[email protected]:username/awesome-personal-project.git
Final repo url for Office Repo
[email protected]:username/awesome-office-project.git
Clone the personal repo using the following command in the terminal
git clone [email protected]:username/awesome-personal-project.git
Clone the office repo using the following command in the terminal
git clone [email protected]:username/awesome-office-project.git
For the existing project, you can change the remote url using the following command
For the personal repo
git remote set-url origin [email protected]:username/awesome-personal-project.git
For the office repo
git remote set-url origin [email protected]:username/awesome-office-project.git
origin is the remote name. We usually have the name of remote name as origin. Remote name could be different from origin. Use the actual remote name if origin name is different from origin.