All posts by Don Matteo

lebt in der Schweiz, ist System Engineer MCP bei A-Enterprise GmbH. Mitglied des UNBLOG Knowledge Network. Author und Blogger zu den Themen, Tutorials für Linux und Open Source.

OpenVPN Client renegotiation after 60 min

Using OpenVPN + 2FA with Google Authenticator

OpenVPN will attempt to have a client renegotiation every 60 minutes (3600 sec) by default, which will prompt the user to enter their 2FA pin to continue the connection.

Renegotiate time

Renegotiate data channel key after n seconds (default=3600). When using a (OTP) one time password, be advised that your connection will automatically drop because your password is not valid anymore. Set to 0 to disable, remember to change on server and client as well.

If you want unlimited connection without these interruptions, update the /etc/openvpn/client-template.txt file and add reneg-sec 0 parameter, this file can look like this:

dev tun
persist-tun
persist-key
data-ciphers-fallback AES-256-CBC
auth SHA512
client
resolv-retry infinite
reneg-sec 0
remote 203.0.113.1 1194 udp
lport 0
verify-x509-name "C=IT, ST=IT, L=example, O=Azienda, emailAddress=hostmaster@example.tld, CN=OPN.example.tld" subject
remote-cert-tls server
auth-user-pass
auth-nocache
compress

Community Edition

The OpenVPN Community Edition is an open source Virtual Private Network (VPN) project. It creates secure connections over the Internet using a custom security protocol that utilizes SSL/TLS. This community-supported OSS (Open Source Software) project, using a GPL license. developers and contributors as well as the extended community. CE is free to deploy, but it does require a strong understanding of Linux and using the command line interface.

OpenVPN Tunneling Protocol

The OpenVPN tunneling protocol uses the Secure Socket Layer (SSL) encryption protocol to ensure data shared via the Internet remains private using AES-256 encryption. Because the code is available for audits, anyone can find — and fix — vulnerabilities. It’s not only considered the most secure VPN tunneling protocol, it also delivers faster connections and can bypass most firewalls.

Find files by modified date with option mtime

Find is the command of choice when searching for files and their modified date and time using the option mtime. The Find Command Line Tool offers the option mtime and many more, also useful for applied in shell scripts. The find --help command gives help, and man find shows the man page.

Find Files using mtime and atime

find files with option mtime

In the file system, each file has three timestamps that are changed when certain operations are performed on the file:

  • [a] access (read the contents of the file) – atime
  • [b] change state (change the file or its attributes) – ctime
  • [modify] change the contents of the file – mtime

Files can be searched for with timestamps within a certain age range, or they can be compared to other timestamps.

Find Files with Option -mtime (modify)

The -mtime option returns a list of files if the file was last accessed N*24 hours ago. For example, to find a file from the last month (N=30 days), the -mtime +30 option can be used.

  • -mtime +30 means find file modified 30 days ago.
  • -mtime -30 means less than 30 days.
  • -mtime 30 without + or – means exactly 30 days.

For example, to find text files that were last modified 30 days ago, ran this command:

$ find /home/user -iname "*.txt" -mtime -30 -print

Show contents of files last modified 30 days ago ran the command:

$ find /home/user -iname "*.txt" -mtime -30 -exec cat {} \;

Count the total number of TXT files using wc (Word Count):

$ find /home/user -iname "*.txt" -mtime -30 | wc -l

Delete gzip archive files older than 30 days with ran this command:

$ find /home/user/*.gz -mtime +30 -exec rm {} \;

Find Files with Option -atime (access)

Search by access time, the following command returns the list of all .txt files that have been accessed in the last 30 days:

$ find /home/user -iname "*.txt" -atime -30 -type -f

List all json files accessed exactly 14 days ago:

$ find /home/user -iname "*.json" -atime 14 -type -f

Note. the switch -type f – search for files only exclude directories.

May find some string recursive in all files from the current directory.

$ find . -type f -print0 | xargs -0 grep "some string"

For example, to change all files recursively with chmod from the current directory, but not the directories.

$ find . -type f -print0 | xargs -0 chmod 0644

and vice versa, change all directories recursively with chmod from the current directory, but not the files.

$ find . -type d -print0 | xargs -0 chmod 0755

Find Files with Option -daystart

The -daystart option is used to measure time from the start of the current day instead of 24 hours ago. Find all C++ files (*.CPP) changed yesterday with the following command:

$ find /home/user -iname "*.CPP" -daystart -mtime 1

To list all LOG files in /var/log accessed yesterday use this command:

$ find /var/log -iname "*.log" -daystart -type f -mtime 1

List C++ files modified 2-7 days ago with this command:

$ find /home/user -iname "*.CPP" -daystart -mtime 2 -mtime -7

To find files in the /home/user directory tree that are newer than the files in /mnt/user, ran the command:

$ find home/user -newer /mnt/user

Conclusion

The find command-line tool can be used in the Linux shell to find files by their modification date. With its numerous options, the Command Line Tool offers many possibilities, which are also useful in script processing.