How to setup .ssh/config for git on non-standard port












0















I know something similar has been asked multiple times, but I wasn't able to find the right solution for my case.



I have a custom git repository accessible via ssh on a non-standard port; URL is something like:



git clone ssh://myname@my.repo.host:12345/path/to/repo/project.git


private key for that repo is in ~/.ssh/myname.prv.



I am trying to get access the repo without passwords, but I'm failing.



My current ~/.ssh/config has a stanza:



Host git
HostName my.repo.host
Port 12345
User myname
IdentityFile ~/.ssh/myname.prv


... but git still asks for a PW.



What am I missing?



Note: both server and client are fairly recent Linux machines and I'm working at the command line, if it matters.










share|improve this question



























    0















    I know something similar has been asked multiple times, but I wasn't able to find the right solution for my case.



    I have a custom git repository accessible via ssh on a non-standard port; URL is something like:



    git clone ssh://myname@my.repo.host:12345/path/to/repo/project.git


    private key for that repo is in ~/.ssh/myname.prv.



    I am trying to get access the repo without passwords, but I'm failing.



    My current ~/.ssh/config has a stanza:



    Host git
    HostName my.repo.host
    Port 12345
    User myname
    IdentityFile ~/.ssh/myname.prv


    ... but git still asks for a PW.



    What am I missing?



    Note: both server and client are fairly recent Linux machines and I'm working at the command line, if it matters.










    share|improve this question

























      0












      0








      0








      I know something similar has been asked multiple times, but I wasn't able to find the right solution for my case.



      I have a custom git repository accessible via ssh on a non-standard port; URL is something like:



      git clone ssh://myname@my.repo.host:12345/path/to/repo/project.git


      private key for that repo is in ~/.ssh/myname.prv.



      I am trying to get access the repo without passwords, but I'm failing.



      My current ~/.ssh/config has a stanza:



      Host git
      HostName my.repo.host
      Port 12345
      User myname
      IdentityFile ~/.ssh/myname.prv


      ... but git still asks for a PW.



      What am I missing?



      Note: both server and client are fairly recent Linux machines and I'm working at the command line, if it matters.










      share|improve this question














      I know something similar has been asked multiple times, but I wasn't able to find the right solution for my case.



      I have a custom git repository accessible via ssh on a non-standard port; URL is something like:



      git clone ssh://myname@my.repo.host:12345/path/to/repo/project.git


      private key for that repo is in ~/.ssh/myname.prv.



      I am trying to get access the repo without passwords, but I'm failing.



      My current ~/.ssh/config has a stanza:



      Host git
      HostName my.repo.host
      Port 12345
      User myname
      IdentityFile ~/.ssh/myname.prv


      ... but git still asks for a PW.



      What am I missing?



      Note: both server and client are fairly recent Linux machines and I'm working at the command line, if it matters.







      linux ssh git openssh






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 20 '18 at 13:40









      ZioByteZioByte

      200111




      200111






















          1 Answer
          1






          active

          oldest

          votes


















          2














          I believe you are misunderstanding the use of the ~/.ssh/config file. You have:



          Host git
          HostName my.repo.host
          ...


          However, the first line Host git defines the name (alias) (i.e. git) of the host to connect to and that which you specify on the command line to either ssh or git. That is, you could now ssh to your git remote server via



          ssh git


          ... and you can clone the git repo using your 'custom' hostname using:



          git clone ssh://git/path/to/repo/project.git


          Note that your remote will now list origin as exactly that address, which is dependent upon your ssh config file.



          Alternatively, if you wish to retain the my.repo.host in the address of your git remote, change your ~/.ssh/config to read:



          Host my.repo.host
          #HostName my.repo.host
          Port 12345
          User myname
          IdentityFile ~/.ssh/myname.prv


          ( NOTE: The HostName directive is redundant in this case, so I left it commented out. )



          With that, you could simplify your remote and clone using:



          git clone ssh://my.repo.host/path/to/repo/project.git





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1386282%2fhow-to-setup-ssh-config-for-git-on-non-standard-port%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            I believe you are misunderstanding the use of the ~/.ssh/config file. You have:



            Host git
            HostName my.repo.host
            ...


            However, the first line Host git defines the name (alias) (i.e. git) of the host to connect to and that which you specify on the command line to either ssh or git. That is, you could now ssh to your git remote server via



            ssh git


            ... and you can clone the git repo using your 'custom' hostname using:



            git clone ssh://git/path/to/repo/project.git


            Note that your remote will now list origin as exactly that address, which is dependent upon your ssh config file.



            Alternatively, if you wish to retain the my.repo.host in the address of your git remote, change your ~/.ssh/config to read:



            Host my.repo.host
            #HostName my.repo.host
            Port 12345
            User myname
            IdentityFile ~/.ssh/myname.prv


            ( NOTE: The HostName directive is redundant in this case, so I left it commented out. )



            With that, you could simplify your remote and clone using:



            git clone ssh://my.repo.host/path/to/repo/project.git





            share|improve this answer




























              2














              I believe you are misunderstanding the use of the ~/.ssh/config file. You have:



              Host git
              HostName my.repo.host
              ...


              However, the first line Host git defines the name (alias) (i.e. git) of the host to connect to and that which you specify on the command line to either ssh or git. That is, you could now ssh to your git remote server via



              ssh git


              ... and you can clone the git repo using your 'custom' hostname using:



              git clone ssh://git/path/to/repo/project.git


              Note that your remote will now list origin as exactly that address, which is dependent upon your ssh config file.



              Alternatively, if you wish to retain the my.repo.host in the address of your git remote, change your ~/.ssh/config to read:



              Host my.repo.host
              #HostName my.repo.host
              Port 12345
              User myname
              IdentityFile ~/.ssh/myname.prv


              ( NOTE: The HostName directive is redundant in this case, so I left it commented out. )



              With that, you could simplify your remote and clone using:



              git clone ssh://my.repo.host/path/to/repo/project.git





              share|improve this answer


























                2












                2








                2







                I believe you are misunderstanding the use of the ~/.ssh/config file. You have:



                Host git
                HostName my.repo.host
                ...


                However, the first line Host git defines the name (alias) (i.e. git) of the host to connect to and that which you specify on the command line to either ssh or git. That is, you could now ssh to your git remote server via



                ssh git


                ... and you can clone the git repo using your 'custom' hostname using:



                git clone ssh://git/path/to/repo/project.git


                Note that your remote will now list origin as exactly that address, which is dependent upon your ssh config file.



                Alternatively, if you wish to retain the my.repo.host in the address of your git remote, change your ~/.ssh/config to read:



                Host my.repo.host
                #HostName my.repo.host
                Port 12345
                User myname
                IdentityFile ~/.ssh/myname.prv


                ( NOTE: The HostName directive is redundant in this case, so I left it commented out. )



                With that, you could simplify your remote and clone using:



                git clone ssh://my.repo.host/path/to/repo/project.git





                share|improve this answer













                I believe you are misunderstanding the use of the ~/.ssh/config file. You have:



                Host git
                HostName my.repo.host
                ...


                However, the first line Host git defines the name (alias) (i.e. git) of the host to connect to and that which you specify on the command line to either ssh or git. That is, you could now ssh to your git remote server via



                ssh git


                ... and you can clone the git repo using your 'custom' hostname using:



                git clone ssh://git/path/to/repo/project.git


                Note that your remote will now list origin as exactly that address, which is dependent upon your ssh config file.



                Alternatively, if you wish to retain the my.repo.host in the address of your git remote, change your ~/.ssh/config to read:



                Host my.repo.host
                #HostName my.repo.host
                Port 12345
                User myname
                IdentityFile ~/.ssh/myname.prv


                ( NOTE: The HostName directive is redundant in this case, so I left it commented out. )



                With that, you could simplify your remote and clone using:



                git clone ssh://my.repo.host/path/to/repo/project.git






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 20 '18 at 16:32









                eggoeggo

                1,301612




                1,301612






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1386282%2fhow-to-setup-ssh-config-for-git-on-non-standard-port%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy