Login with SSH authorized key with changed SSH port












4















I changed my SSH port in the /etc/ssh/sshd_config file and then restarted the ssh service. I implemented fail2ban and updated the port to my SSH under that config. I also then implemented the UFW firewall and allowed incoming connections to my new SSH port.



However, when I try and login with my SSH key using ssh -i /Users/myuser/.ssh/vpsssh user@555.555.555.555 it's trying to connect to port 22 instead of the defined port I have.










share|improve this question


















  • 2





    Server and client do not about each other automatically. They both use the default port 22, unles is changed, on sshd_config for server, or specified on command for cliente like here

    – bistoco
    2 days ago






  • 1





    They could be trying to login to an Ubuntu server from a Windows PC, which I think is still on topic.

    – Arronical
    2 days ago











  • Is there a reason you're using a different key for each host you connect to?

    – R..
    yesterday
















4















I changed my SSH port in the /etc/ssh/sshd_config file and then restarted the ssh service. I implemented fail2ban and updated the port to my SSH under that config. I also then implemented the UFW firewall and allowed incoming connections to my new SSH port.



However, when I try and login with my SSH key using ssh -i /Users/myuser/.ssh/vpsssh user@555.555.555.555 it's trying to connect to port 22 instead of the defined port I have.










share|improve this question


















  • 2





    Server and client do not about each other automatically. They both use the default port 22, unles is changed, on sshd_config for server, or specified on command for cliente like here

    – bistoco
    2 days ago






  • 1





    They could be trying to login to an Ubuntu server from a Windows PC, which I think is still on topic.

    – Arronical
    2 days ago











  • Is there a reason you're using a different key for each host you connect to?

    – R..
    yesterday














4












4








4


1






I changed my SSH port in the /etc/ssh/sshd_config file and then restarted the ssh service. I implemented fail2ban and updated the port to my SSH under that config. I also then implemented the UFW firewall and allowed incoming connections to my new SSH port.



However, when I try and login with my SSH key using ssh -i /Users/myuser/.ssh/vpsssh user@555.555.555.555 it's trying to connect to port 22 instead of the defined port I have.










share|improve this question














I changed my SSH port in the /etc/ssh/sshd_config file and then restarted the ssh service. I implemented fail2ban and updated the port to my SSH under that config. I also then implemented the UFW firewall and allowed incoming connections to my new SSH port.



However, when I try and login with my SSH key using ssh -i /Users/myuser/.ssh/vpsssh user@555.555.555.555 it's trying to connect to port 22 instead of the defined port I have.







ssh login






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









user1048676user1048676

1475




1475








  • 2





    Server and client do not about each other automatically. They both use the default port 22, unles is changed, on sshd_config for server, or specified on command for cliente like here

    – bistoco
    2 days ago






  • 1





    They could be trying to login to an Ubuntu server from a Windows PC, which I think is still on topic.

    – Arronical
    2 days ago











  • Is there a reason you're using a different key for each host you connect to?

    – R..
    yesterday














  • 2





    Server and client do not about each other automatically. They both use the default port 22, unles is changed, on sshd_config for server, or specified on command for cliente like here

    – bistoco
    2 days ago






  • 1





    They could be trying to login to an Ubuntu server from a Windows PC, which I think is still on topic.

    – Arronical
    2 days ago











  • Is there a reason you're using a different key for each host you connect to?

    – R..
    yesterday








2




2





Server and client do not about each other automatically. They both use the default port 22, unles is changed, on sshd_config for server, or specified on command for cliente like here

– bistoco
2 days ago





Server and client do not about each other automatically. They both use the default port 22, unles is changed, on sshd_config for server, or specified on command for cliente like here

– bistoco
2 days ago




1




1





They could be trying to login to an Ubuntu server from a Windows PC, which I think is still on topic.

– Arronical
2 days ago





They could be trying to login to an Ubuntu server from a Windows PC, which I think is still on topic.

– Arronical
2 days ago













Is there a reason you're using a different key for each host you connect to?

– R..
yesterday





Is there a reason you're using a different key for each host you connect to?

– R..
yesterday










2 Answers
2






active

oldest

votes


















22














You can specify a non-default port on the ssh client command line using the -p option. From man ssh:



 -p port
Port to connect to on the remote host. This can be specified on
a per-host basis in the configuration file.


You may wish to put both the port number and the identity file location for the host in a ~/.ssh/config file so that they don't need to be specified every time on the command line.



Ex.



Host myremotehost
Hostname 555.555.555.555
User user
Port 20002
IdentityFile /Users/myuser/.ssh/vpsssh


Then you will be able to use:



ssh myremotehost





share|improve this answer


























  • Probably useful to many when you start defining that kind of configuration: How do I configure SSH so it dosen't try all the identity files automatically?.

    – Giacomo Alzetta
    yesterday



















6














Note that ssh accepts commands in the URI form, such as ssh://user@host.com:<port>. Based on that, what I do when logging in to a remote server with a private key is the following:



ssh -i ~/.ssh/id_rsa ssh://myuser@domain_name.com:2222





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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%2faskubuntu.com%2fquestions%2f1111994%2flogin-with-ssh-authorized-key-with-changed-ssh-port%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    22














    You can specify a non-default port on the ssh client command line using the -p option. From man ssh:



     -p port
    Port to connect to on the remote host. This can be specified on
    a per-host basis in the configuration file.


    You may wish to put both the port number and the identity file location for the host in a ~/.ssh/config file so that they don't need to be specified every time on the command line.



    Ex.



    Host myremotehost
    Hostname 555.555.555.555
    User user
    Port 20002
    IdentityFile /Users/myuser/.ssh/vpsssh


    Then you will be able to use:



    ssh myremotehost





    share|improve this answer


























    • Probably useful to many when you start defining that kind of configuration: How do I configure SSH so it dosen't try all the identity files automatically?.

      – Giacomo Alzetta
      yesterday
















    22














    You can specify a non-default port on the ssh client command line using the -p option. From man ssh:



     -p port
    Port to connect to on the remote host. This can be specified on
    a per-host basis in the configuration file.


    You may wish to put both the port number and the identity file location for the host in a ~/.ssh/config file so that they don't need to be specified every time on the command line.



    Ex.



    Host myremotehost
    Hostname 555.555.555.555
    User user
    Port 20002
    IdentityFile /Users/myuser/.ssh/vpsssh


    Then you will be able to use:



    ssh myremotehost





    share|improve this answer


























    • Probably useful to many when you start defining that kind of configuration: How do I configure SSH so it dosen't try all the identity files automatically?.

      – Giacomo Alzetta
      yesterday














    22












    22








    22







    You can specify a non-default port on the ssh client command line using the -p option. From man ssh:



     -p port
    Port to connect to on the remote host. This can be specified on
    a per-host basis in the configuration file.


    You may wish to put both the port number and the identity file location for the host in a ~/.ssh/config file so that they don't need to be specified every time on the command line.



    Ex.



    Host myremotehost
    Hostname 555.555.555.555
    User user
    Port 20002
    IdentityFile /Users/myuser/.ssh/vpsssh


    Then you will be able to use:



    ssh myremotehost





    share|improve this answer















    You can specify a non-default port on the ssh client command line using the -p option. From man ssh:



     -p port
    Port to connect to on the remote host. This can be specified on
    a per-host basis in the configuration file.


    You may wish to put both the port number and the identity file location for the host in a ~/.ssh/config file so that they don't need to be specified every time on the command line.



    Ex.



    Host myremotehost
    Hostname 555.555.555.555
    User user
    Port 20002
    IdentityFile /Users/myuser/.ssh/vpsssh


    Then you will be able to use:



    ssh myremotehost






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 2 days ago









    pa4080

    13.9k52564




    13.9k52564










    answered 2 days ago









    steeldriversteeldriver

    67k11108180




    67k11108180













    • Probably useful to many when you start defining that kind of configuration: How do I configure SSH so it dosen't try all the identity files automatically?.

      – Giacomo Alzetta
      yesterday



















    • Probably useful to many when you start defining that kind of configuration: How do I configure SSH so it dosen't try all the identity files automatically?.

      – Giacomo Alzetta
      yesterday

















    Probably useful to many when you start defining that kind of configuration: How do I configure SSH so it dosen't try all the identity files automatically?.

    – Giacomo Alzetta
    yesterday





    Probably useful to many when you start defining that kind of configuration: How do I configure SSH so it dosen't try all the identity files automatically?.

    – Giacomo Alzetta
    yesterday













    6














    Note that ssh accepts commands in the URI form, such as ssh://user@host.com:<port>. Based on that, what I do when logging in to a remote server with a private key is the following:



    ssh -i ~/.ssh/id_rsa ssh://myuser@domain_name.com:2222





    share|improve this answer




























      6














      Note that ssh accepts commands in the URI form, such as ssh://user@host.com:<port>. Based on that, what I do when logging in to a remote server with a private key is the following:



      ssh -i ~/.ssh/id_rsa ssh://myuser@domain_name.com:2222





      share|improve this answer


























        6












        6








        6







        Note that ssh accepts commands in the URI form, such as ssh://user@host.com:<port>. Based on that, what I do when logging in to a remote server with a private key is the following:



        ssh -i ~/.ssh/id_rsa ssh://myuser@domain_name.com:2222





        share|improve this answer













        Note that ssh accepts commands in the URI form, such as ssh://user@host.com:<port>. Based on that, what I do when logging in to a remote server with a private key is the following:



        ssh -i ~/.ssh/id_rsa ssh://myuser@domain_name.com:2222






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        Sergiy KolodyazhnyySergiy Kolodyazhnyy

        71.5k9147313




        71.5k9147313






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f1111994%2flogin-with-ssh-authorized-key-with-changed-ssh-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

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]