19 C
Jaipur
Wednesday, October 28, 2020

Git Remote Add With Another SSH Port (Not 22)

Must read

Samsung Galaxy S21 May Ditch Bundled Earphones And Charger Like Apple

A few weeks ago, Apple made headlines after announcing that the iPhone 12 won’t ship with a charger or a pair of earphones. And now it...

China launches crackdown on mobile web browsers, decries ‘chaos’ of information – Latest News

China's top cyber authority said it would carry out a "rectification" of Chinese mobile internet browsers to address what it called social concerns over...

cellphone: Japan unveils plan to prod carriers to cut cellphone charges – Latest News

Japan on Tuesday laid out a plan for reducing consumers' cellphone charges, as the government stepped up its bid to promote competition in the...

Uniqlo: Japanese apparel retailer Uniqlo forays into Indian online market – Latest News

Japanese global apparel retailer UNIQLO on Tuesday said it has forayed into the Indian online market. The company has introduced 'Shop From Home' service...

In this brief article, you will learn to add a git remote with another SSH Port. By default, SSH server listens on port 22. If the SSH server runs on any other port, the command to add remote will fail with error ssh: connect to host 192.158.xx.xx port 22: Connection refuse.

What is Git?

Git is a free & open-source version control system that almost all developers use today. No matter what project you’re working on, Git can help you manage your code efficiently.

It is faster than any other way of transmitting code to a remote location. Its lightening fast performance can transmit the entire application within seconds to the production server, staging server or a bitbucket repository.

To learn more about git, read our Learn Git series.

Git remote add

After initializing the local repository, one needs to add at least one remote repository to push code to that remote. By default, git requires a server username and IP address to add a remote repository.

git remote add remote_name ssh://[email protected]_address/path-to-git-repo/repo.git

Example –

git remote add production ssh://[email protected]/var/repositories/lau.git

The above command will add a remote named production. If you changed the SSH port, the above remote will fail to push code and return the following error –

ssh: connect to host 192.168.28.235 port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

It means git tried to connect to ssh on port 22. Since the port 22 has been modified, we need to specify another port when adding a remote.

Git Remote Add With Another SSH Port

git remote add ssh://[email protected]_address:port/path-to-git-repo/repo.git

Example –

git remote add ssh://[email protected]:3234/var/repository/lau.git
Git Remote Add With Another SSH Port

As you can see, the custom port needs to be specified while adding the remote. Now the above command will add a remote that will push code to repository on SSH port 3234.

LinuxAndUbuntu hosting is sponsored by massiveGRID

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Samsung Galaxy S21 May Ditch Bundled Earphones And Charger Like Apple

A few weeks ago, Apple made headlines after announcing that the iPhone 12 won’t ship with a charger or a pair of earphones. And now it...

China launches crackdown on mobile web browsers, decries ‘chaos’ of information – Latest News

China's top cyber authority said it would carry out a "rectification" of Chinese mobile internet browsers to address what it called social concerns over...

cellphone: Japan unveils plan to prod carriers to cut cellphone charges – Latest News

Japan on Tuesday laid out a plan for reducing consumers' cellphone charges, as the government stepped up its bid to promote competition in the...

Uniqlo: Japanese apparel retailer Uniqlo forays into Indian online market – Latest News

Japanese global apparel retailer UNIQLO on Tuesday said it has forayed into the Indian online market. The company has introduced 'Shop From Home' service...

waymo: Waymo, Daimler partner to make self-driving trucks – Latest News

Alphabet Inc's autonomous driving technology development unit, Waymo, and a division of Germany's luxury carmaker Daimler AG have teamed up to make heavy-duty, self-driving...