Login with SSH authorized key with changed SSH port

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












5















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
    Jan 22 at 15:35






  • 1





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

    – Arronical
    Jan 22 at 17:13











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

    – R..
    Jan 23 at 17:41















5















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
    Jan 22 at 15:35






  • 1





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

    – Arronical
    Jan 22 at 17:13











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

    – R..
    Jan 23 at 17:41













5












5








5


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 Jan 22 at 15:32









user1048676user1048676

1525




1525







  • 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
    Jan 22 at 15:35






  • 1





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

    – Arronical
    Jan 22 at 17:13











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

    – R..
    Jan 23 at 17:41












  • 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
    Jan 22 at 15:35






  • 1





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

    – Arronical
    Jan 22 at 17:13











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

    – R..
    Jan 23 at 17:41







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
Jan 22 at 15:35





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
Jan 22 at 15:35




1




1





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

– Arronical
Jan 22 at 17:13





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

– Arronical
Jan 22 at 17:13













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

– R..
Jan 23 at 17:41





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

– R..
Jan 23 at 17:41










2 Answers
2






active

oldest

votes


















25














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
    Jan 23 at 14:46


















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









    25














    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
      Jan 23 at 14:46















    25














    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
      Jan 23 at 14:46













    25












    25








    25







    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 Jan 22 at 15:43









    pa4080

    14.1k52666




    14.1k52666










    answered Jan 22 at 15:35









    steeldriversteeldriver

    67.5k11110181




    67.5k11110181












    • 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
      Jan 23 at 14:46

















    • 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
      Jan 23 at 14:46
















    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
    Jan 23 at 14:46





    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
    Jan 23 at 14:46













    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 Jan 23 at 1:30









        Sergiy KolodyazhnyySergiy Kolodyazhnyy

        71.9k9148314




        71.9k9148314



























            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

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay