How to listen to a certain port

Posted November 15, 2017 2.7k views

Hi. I have an Apache Server with a LAMP Stack running on Ubuntu 14.04.

It’s all set up well, but I also need to monitor messages coming in from Port 22. I’ve opened the port using ufw, but I don’t know how to listen to it.

Any help will be very much appreciated.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Port 22 is generally used for SSH traffic. If you configure another application besides the SSH daemon to listen on that port, make sure to configure SSH to listen on a different port first. If not, you may lose access to the server.

If you really want to configure Apache to listen to port 22, you must add or edit a VirtualHost to do so as well as configure a Listen directive. The port that Apache will respond on is configured

Listen 22

<VirtualHost *:22>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

For more information on configuring Apache, check out:

To learn more about SSH, see:

by Justin Ellingwood
SSH, or secure shell, is the most common way of connecting to and administering remote Linux servers. In this cheat sheet-style guide, we'll cover some of the basic options and configuration sets you may want to use.