Welcome to Centmin Mod Community
Register Now

[Solved] Changing SSH Port

Discussion in 'Bug Reports' started by Jimmy, Nov 7, 2018.

  1. Jimmy

    Jimmy Premium Member Premium Member

    1,415
    292
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +723
    Local Time:
    7:41 AM
    1.13.x
    MariaDB 10.1.x
    Please fill in any relevant information that applies to you:
    • CentOS Version: i.e. CentOS 7 64bit ?
    • Centmin Mod Version Installed: i.e. 123.09beta01
    • PHP Version Installed: i.e. 7.2.11
    1. New beta01 install.
    2. cmdir, centmin, option 16
    3. Asks for default port enter 22
    4. Asks for a new port 9348. Set the port to a port which is already used by the system (9348). Restart sshd.
    5. Logout
    6. SSH login with new port (9348). SSH fails because the script didn't un-comment the line in the sshd_config for obvious reasons (port in use). Have to use port 22.
    7. cmdir, centmin, option 16
    8. Asks for existing port. (22 or 9348) Says 9348 is used by the system but is the current set port. Need to enter a port which isn't in use "9808". Restart sshd.
    9. Logout
    10. SSH login with new port (9808). SSH fails because the script didn't un-comment the line in the sshd_config. Have to use port 22.
    I had to go into the sshd_config file and un-comment the "Port 9808" so it became active. Otherwise, it keeps failing when connecting leading to someone thinking they entered the wrong port, in the config file, when in actuality it's still port 22 because the Port XXX in the file is still commented.

    I only did this once. Didn't have time to test it on other machines. Nevertheless, wanted to report it.
     
    Last edited: Nov 7, 2018
    • Informative Informative x 1
  2. eva2000

    eva2000 Administrator Staff Member

    36,915
    8,074
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,438
    Local Time:
    10:41 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    strange i can't see how that is happening unless your /etc/ssh/sshd_config has a different format for the port entry

    centmin mod is looking for entry like
    Code (Text):
    #Port 22
    

    to uncomment via sed replacement. If you entry has a spacing format different
    i.e.
    Code (Text):
    #Port    22
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    36,915
    8,074
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,438
    Local Time:
    10:41 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    oh missed that part - then it's normal, if you set to a new sshd port that is already in use, centmin mod will skip changing sshd port in /etc/ssh/sshd_config

    I guess this is where the bug is then
     
  4. eva2000

    eva2000 Administrator Staff Member

    36,915
    8,074
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,438
    Local Time:
    10:41 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    FYI, just updated 123.09beta01 with a possible fix for this :)

    cmupdate command will up date your local centmin mod code
    Code (Text):
    cmupdate
    No local changes to save
    remote: Enumerating objects: 13, done.
    remote: Counting objects: 100% (12/12), done.
    remote: Compressing objects: 100% (1/1), done.
    remote: Total 5 (delta 4), reused 5 (delta 4), pack-reused 0
    Unpacking objects: 100% (5/5), done.
    From https://github.com/centminmod/centminmod
       686ca21..b3ead9b  123.09beta01 -> origin/123.09beta01
    Updating 686ca21..b3ead9b
    Fast-forward
     centmin.sh   | 4 +++-
     inc/sshd.inc | 6 +++++-
     2 files changed, 8 insertions(+), 2 deletions(-)
    
     
    • Like Like x 1
  5. Jimmy

    Jimmy Premium Member Premium Member

    1,415
    292
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +723
    Local Time:
    7:41 AM
    1.13.x
    MariaDB 10.1.x
    Thanks! It was funny because for about 10 minutes I was guessing ports until I decided to try 22.
     
    • Like Like x 1
..