How to change the SSH port number on a Linux server

Follow

Comments

12 comments

  • Avatar
    Cirrus

    When changing SSH port, shouldn't related fail2ban jail be adjusted, too?

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    Hi Cirrus, yes it is also required to update fail2ban configuration. The article will be updated accordingly. 

    0
    Comment actions Permalink
  • Avatar
    John Bertin (Edited )

    Following this tutorial I was no longer access the server using SSH 

    After a bit of searching, I discovered that it is also necessary to add a custom rule in the Plesk firewall. Once I did this, I was able to access console on the new port. 

    PS. please update the guide to help others avoid being locked out as well. I used the following guide to solve the issue: https://support.plesk.com/hc/en-us/articles/115001078014-How-to-manage-firewall-rules-on-a-Plesk-for-Linux-server

     

     

     

     

    1
    Comment actions Permalink
  • Avatar
    Ivan Postnikov (Edited )

    @John,

    Yes, you are correct, the required port should be opened for connection in Plesk firewall or any alternative, which is used.

    That is why in the article we have the following note:

    "the new port must be opened in firewall."

    0
    Comment actions Permalink
  • Avatar
    BP

    If you use a custom SSH port, the local GIT deployment configuration should consider this port as well when providing instructions: https://docs.plesk.com/en-US/onyx/administrator-guide/website-management/git-support/using-a-local-repository.75825/. Otherwise (i.e., right now), this renders the instructions useless since commands need to be changed manually.

    0
    Comment actions Permalink
  • Avatar
    Alexandr Nikolaenko

    Hello b_p,

    Thank you for bringing this to our attention. Indeed, in order to use GIT deployment over ssh the command should be modified to below ("ssh://" URL does not support relative paths):
    # git remote add origin ssh://user@example.com:22:/var/www/vhosts/example.com/git/test.git

    I will create a request to a concerned department to add a corresponding note to the documentation.

     

    0
    Comment actions Permalink
  • Avatar
    Grzegorz Wołoszyn

    Can you consider adding port information in client section where only IP address is visible?

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    Hello Grzegorz, could you please clarify a bit more for me where exactly you'd like to see it? Ideally with a screenshot. 

    0
    Comment actions Permalink
  • Avatar
    Kyllaz (Edited )

    Did all the steps but now i cannot login to SSH anymore, on port 22 it says conection refused and on the port i defined it says connection timed out. Any help on this? Btw i added it on plesk firewall as both income and outgoing rules.

    0
    Comment actions Permalink
  • Avatar
    Ezee Login

    It seems like you're not running SSH on port 26 on the second machine. You can either change the port number on that machine to 26.

    0
    Comment actions Permalink
  • Avatar
    amine ben

    ssh terminal in plesk is nor working after port change, still try to use port 22.

    How to fix this plz

    1
    Comment actions Permalink
  • Avatar
    Sam

    Confirmed that the Terminal window within the Plesk Admin Interface (Tools & Settings > SSH Terminal) no longer functions after changing to a custom SSH port, as it continues to attempt to access over port 22. This is even the case if you reboot the server.

    In fact, trying to access the Terminal page results in repeating error notifications in the UI, even if you back out of the page. You have to reload the admin interface in the browser to stop them.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request