ssh-port

How to perform Time Scheduling on an SSH Port? 

ssh port

A network administrator could further secure running services on a server by getting the tasks scheduled. SSH service could be scheduled as well when it comes to setting a timing limit of the run SSH service on the server. This basically adds another essential layer of security inside a network.

For the sake of accomplishing our desired task, we need to make use of the Linux utility named Cron. The unique thing about this utility is that it allows for a command or a script to get scheduled to get run automatically according to a particular time and date set before. The scheduled task is considered as the Cron’s job in the first place.

The following steps provide us with a comprehensive means of getting such time scheduling set up.

  • Open the terminal and type the following command to get the SSH service started
    Service ssh start
  • Make sure that the SSH service is active and running by typing the following command:
    Service ssh status
  • Since crontab is already a built-in utility inside a Linux operating system, so let’s load it using the following command using the root privileges:
    sudo crontab –e
  • The GNU nano will mostly be responsible for getting the crontab interface open on Linux.
  • It is very important to note that the type of commands used in Crontab is what is referred to as (m h dom mon dow [command]). To elaborate on such format, the following table displays the values which each field could take and vary between.
Field  value 
’m’ which stands for minute  0-59
‘h’ which stands for hour  0-23
‘dom’ which stands for date  1-31
‘mon’ whih stands for month  1-12
‘dow’ which stands for day of week  1-7[1 stands for Monday and then it goes up respectively]
command  the required command to be
  • Let’s consider an example where we need to set a task scheduled on Monday at 8:00 am. This is interpreted in terms of the m h dom mon dow language as:
    0 8 * * 1 [command]
  • Let’s get back to our original task where we need to get SSH service scheduled using crontab. Accordingly, if we need to get the SSH service activated for 3 minutes after which it will take 4 minutes without service. The command should then look like the following command
    * * * * * sleep 180;/usr/sbin/service ssh start

    is important to note that the number 180 is written in terms of seconds not anything else. This means that 3 minutes is, of course, equals to 3*60=180 seconds

  • Now, we need to get to make sure that the service is to stop 4 minutes right after running. Then, the number of seconds to be used= 4*60=240 seconds. The following command will be of a great use thereby.
    * * * * * sleep 240;/usr/sbin/service ssh stop
  • In order to make sure that the previous commands work, the following commands could be useful in this case. First, the service should be rebooted first of all. The following command will scan the port number 22 where SSH essentially works to know whether it is open or closed. One of the best tools to use for this kind of scanning is definitely Nmap.
    nmap  -p 22 127.0.0.1
  • The last command should show that the port is open when we test it. But, after waiting for 4 minutes, we should repeat the command again as follows:
    nmap  -p 22 127.0.0.1
  • This time, the last command should show that port number 22 is closed now after these 4 minutes. The fourth minute’s scan result will show that it is closed. This means that the schedule works very well!
  • Let’s now add some small modification into the last schedule which we just set. Let’s consider that we decided that such task is to get started at 06:00 am in the first place. And let’s be more specific and specify that the service is to get closed at 06:00 pm.
  • The following two commands will be responsible for the tasks of opening and closing the service respectively.
    0 6 * * * /usr/sbin/service ssh start
    0 18 * * * /usr/sbin/service ssh stop
  • This means that if we scan port number 22 using Nmap on any random day between 6 am in the morning and its counterpart in the evening, the port should be shown as an open one. Otherwise, the port should appear as a closed port.

 

Let’s get to know more about Nmap security tool:

ssh port

Network Mapper (Nmap) is one of the best security utilities used for the sake of performing a security audit or discover a network and its packages. Being a free software and an open source project, it has become very popular when it comes to network security and this field’s professionals.

It could be utilized for different purposes, from which the following list is given:

  • As a network inventory
  • The schedules of a service upgrade could be performed using the software as well.
  • A server or a host could be monitored to know whether it is up and running or down.
  • Raw IP packets are utilized by Nmap for the sake of getting to know:
  • which servers are up and running on the network and which of them are actually not.
  • Also, such raw packets are depended on when it comes to identifying the services of such hosts including the name and version of the applications.
  • Getting to know the operating system of such hosts gets known by Nmap as well.
  • Even the used firewalls or as they are referred to as packet filters can be known using Nmap.

While in fact, such software works the best when operating inside an extensive network, it still has the capability to work on a single host as desired. A lot of operating systems is supported to run such software such as Linux, Microsoft Windows, FreeBSD, OpenBSD, Solaris, IRIX, Mac OS X, HP-UX, NetBSD, Sun OS, Amiga, and more. In addition, Linux, Windows, and Mac OS X have their official binary packages of the software.

Try Certified Ethical Hacker for FREE!!!https://infosecaddicts.com/course/certified-ethical-hacker-v10/

References

http://www.hackingarticles.in/beginner-guide-ssl-tunneling-dynamic-tunneling/

http://www.hackingarticles.in/perform-local-ssh-tunneling/

https://en.wikipedia.org/wiki/Tunneling_protocol

https://en.wikipedia.org/wiki/SOCKS

https://en.wikipedia.org/wiki/Comparison_of_proxifiers

https://en.wikipedia.org/wiki/TUN/TAP

http://www.hackingarticles.in/perform-remote-tunneling/

http://www.hackingarticles.in/beginner-guide-ssl-tunneling-dynamic-tunneling/

http://linux.byexamples.com/archives/115/ssh-dynamic-tunneling/

https://ypereirareis.github.io/blog/2016/09/19/ssh-tunnel-local-remote-port-forwarding/

https://coderwall.com/p/pmf0tw/understand-local-remote-and-dynamic-ssh-tunneling

http://www.hackingarticles.in/time-scheduling-ssh-port/

http://www.hackingarticles.in/web-server-exploitation-ssh-log-poisoning-lfi/

http://www.hackingarticles.in/metasploitable-3-exploitation-using-brute-forcing-ssh/

http://www.hackingarticles.in/secure-port-using-port-knocking/

https://chamibuddhika.wordpress.com/2012/03/21/ssh-tunnelling-explained/

https://en.wikipedia.org/wiki/RealVNC

https://nmap.org/

http://resources.infosecinstitute.com/metasploitable-2-walkthrough/#gref

https://www.vulnhub.com/entry/metasploitable-2,29/

https://github.com/rapid7/metasploitable3

[ihc-select-level]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.