Git

Git Remote Add With Other SSH Port

Git is an open-source, decentralized tracking tool that is most commonly used among all types of developers nowadays. It can also help the users to manage their project code efficiently. To build a connection between the remote and local repository, it is required to set the remote URL.

Additionally, users can add the β€œHTTPs” or β€œSSH” protocol according to their preference. However, compared to the HTTPs protocol, SSH is the secure way of connecting the local repository with the GitHub hosting server. Moreover, developers can add the SSH port as per requirements.

This guide has elaborated on adding a Git remote with another SSH port.

How to Add Git Remote With Other SSH Port?

Follow the below-listed steps to add the Git remote with another SSH port:

Step 1: Navigate to Git Local Repository

First, utilize the β€œcd” command and switch to the specified repository path:

$ cd "C:\Users\nazma\Git"

Step 2: View Tracking Remote Repository URLs

Then, execute the β€œgit remote” command and check the remote URLs:

$ git remote -v

According to the below-given output, the remote URL list is empty:

Step 3: Copy GitHub Repository URL

Now, go to the GitHub hosting server, and open the desired remote repository. Then, navigate to the β€œCode” button sub-menu, click on the β€œSSH” URL, and copy it to the clipboard:

Step 4: Add Remote URL With SSH Port

Next, execute the provided command along with the copied remote repository path:

$ git remote add origin git@github.com:GitUser0422:2224/demo.git

In the above command, β€œ2224” is the SSH port:

Step 5: Ensure Added Remote URL

Lastly, ensure the tracking remote is added or not by running the below-listed command:

$ git remote -v

It can be observed that the provided SSH URL along with another port number has been added successfully:

That’s all! We have compiled the easiest way of adding the SSH remote URL along with the desired SSH port.

Conclusion

To add the Git remote along with another SSH port, first, move to the Git repository and check the list of remote URLs. Next, open the GitHub hosting server and copy the desired remote repository SSH URL. Then, switch to the Git terminal and run the β€œgit remote add” command along with the SSH URL and desired SSH port. This guide has elaborated on adding a Git remote with another SSH port.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.