Change GIT port

11,955

You can update the port in the SSH URL with git remote set-url CLI command. For example, to update the port of the origin remote to port 321 you can run the following:

git remote set-url origin ssh://[email protected]:321/home/user/repo

If you don't know the rest of the URL you can do

git remote -v

and then just switch the port number.

Share:
11,955
Marsellus Wallace
Author by

Marsellus Wallace

The real Marsellus Wallace

Updated on June 04, 2022

Comments

  • Marsellus Wallace
    Marsellus Wallace almost 2 years

    When I try: git pull origin master I receive the following: ssh: connect to host localhost port 123: Bad file number

    Now, somewhere and somehow I set up git to use port 123 but that is no longer a valid one. I'd like to change it to port 321.

    I went to modify the ~/.ssh/config file but I surprisingly realized that the file does not exist. I could probably create one and get the desired behavior but my question is: where else can the port 123 has been defined? How do I change that to 321 without creating a config file?