Linux – Port 22 has been closed during upgrade (not accessible through SSH/SFTP)

debian-wheezylinux

After upgrading somehow some of the ports have been closed!? Now port 22 is no longer open and the server is not accessible from neither SSH nor SFTP

All other services like apache, mysql, webmin etc. is running as expected

Have tried to reboot the system

Open ports before upgrade

# nmap -PN 127.0.0.1
Host is up (0.0000090s latency).
Not shown: 996 closed ports
PORT      STATE SERVICE
22/tcp    open  ssh
80/tcp    open  http
3306/tcp  open  mysql
10000/tcp open  snet-sensor-mgmt

Open ports after upgrade

# nmap -PN 127.0.0.1
Host is up (0.0011s latency).
Not shown: 998 closed ports
PORT      STATE SERVICE
80/tcp    open  http
10000/tcp open  snet-sensor-mgmt

Below are the exact steps during upgrade. The upgrade has been performed on multiple servers and same issue in all cases with closed ports after the upgrade was completed

1 step: Upgrading mysql 5.6.15 to 5.6.20

service mysql stop
dpkg -r mysql
dpkg -r mysql-client
dpkg -r mysql-client-5.5
dpkg -r mysql-common
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.20-debian6.0-x86_64.deb && dpkg -i mysql-5.6.20-debian6.0-x86_64.deb
cd /usr/local && ln -s /opt/mysql/server-5.6 mysql && cd mysql && scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql
rm /opt/mysql/server-5.6/my.cnf && ln -s /var/ini/my.cnf /opt/mysql/server-5.6/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
update-rc.d mysql defaults
service mysql start

2 step: Further upgrading

apt-get update && apt-get upgrade

What could have gone wrong during the upgrade since some of the ports is no longer open? How to re-open the closed ports?

The following ports are no longer open:

22 ssh
3306 mysql

Mysql is running (the webpage is accessible) But I can't connect to the server through SSH (putty) because port 22 has somehow been closed during upgrade

putty error

Server unexpected closed network connection

enter image description here

Best Answer

IIRC the default MySQL config is not to listen via TCP, but via socket file only, which explains why port 3309 isn't bound after the upgrade. It's likely that somehow you ended up with the default config.

Why sshd isn't running isn't discernable from the commands you shared, but likely some config error that makes sshd bail out on start. Without access to the system for you to give us more information, there's not enough to go on for thinking of anything else.

Update

According to the output you shared, sshd complains that openssl doesn't match its version. Get access to your box and run

apt-get update
apt-get install openssl openssh-server libssl1.0.0

If you get errors on updates, this should fix APT. Be careful though, you need to review your config after this:

apt-get install -f

That should take care of it.