Can't SSH to my dedicated server on Centos 7

Can't SSH to my dedicated server on Centos 7(Unmanaged)

I saw this error & i rebooted my server and couldn't connect/SSH anymore

I messed up some configuration, not sure what to do. i see this error and after rebooted i can't access

sudo: pam_open_session: Error in service module
sudo: policy plugin failed session initialization

This is from support team reply :

But all ports are filtered:

Nmap scan report for **** (xxx.xxx.xxx.xx)
Host is up.
All 1000 scanned ports on **** (xxx.xxx.xxx.xx) are filtered
Nmap done: 1 IP address (1 host up) scanned in 51.35 seconds

I would suggest to access via rescue mode and check the firewall configuration.

I did rescue mode reboot and how do i reset firewall rule or how can fix it ?


Solution 1:

Assuming you use a port like "22" for connecting, you have to check the following:

  • check /etc/ssh/sshd_config to see if the proper port is there (The setting is Port)

  • if you use a different port, it means you should have policycoreutils-python or alterates and use semanage port command to add it.

  • check your firewall ( firewall-cmd --list-all ) to see if that port is in the firewall

  • if it's not there, add it firewall-cmd --add-port **PortNumber**/tcp and make it permanent firewall-cmd --add-port **PortNumber**/tcp --permanent

  • restart the needed services (service sshd restart and firewall-cmd --reload)