Skip to main content

How to set up logrotate for automatic log archiving and saving server space

· 2 min read
Customer Care Engineer

Log management is a crucial part of any server administrator's job. Logs that are not rotated can quickly occupy all available disk space, slow down the server, and cause unpredictable errors. In this article, we’ll explain how to configure and use logrotate for automatic log cleanup and rotation on a server. 


What is logrotate and why is it important to use?

Logrotate is a tool designed for automatic log management. It helps to:

  • Clear old logs — automatically deletes or archives old log files.
  • Save disk space — compresses and removes unnecessary logs.

Log rotation prevents logs from accumulating and causing disk overflow, which could result in crashes and data loss. Logrotate automatically archives old logs and makes room for new data.


How does logrotate work?

When logrotate is active, it automatically performs the following steps:

  1. Log rotation — old logs are renamed and stored, while new files are created in their place.
  2. Compression — old logs can be compressed into .gz format to save space.
  3. Deletion — outdated logs can be deleted if they are no longer needed.

Example: A log file named access.log can be transformed into access.log.1, then compressed into access.log.1.gz, and eventually deleted after a specified retention period.


How to configure logrotate

1. Installing logrotate

On most Linux systems, logrotate is pre-installed. To check if logrotate is installed, run the command:

sudo logrotate --version

 If logrotate is not installed, it can be installed via a package manager. 

  • For Debian/Ubuntu:
sudo apt update && sudo apt install logrotate
  • For CentOS/RockyLinux/AlmaLinux:
sudo yum install logrotate

2. Configuring logrotate

Logrotate configuration is usually stored in /etc/logrotate.conf. This file contains general parameters for all logs on the server. To configure the rotation of individual logs, you can create separate configuration files for different services in the /etc/logrotate.d/ directory.

Example of a standard Nginx configuration:

/var/log/nginx/*.log {
daily          # Logs are rotated daily
missingok      # Do not display an error if the log is missing
rotate 7       # Keep 7 archived files
compress       # Compress old logs
delaycompress  # Delay compression until the next rotation
notifempty     # Do not rotate empty files
create 0640 www-data adm  # Create new logs with specific permissions
}

3. Key configuration parameters

  • daily/weekly/monthly — defines how often the log file will be rotated (daily, weekly, or monthly).
  • rotate [N] — specifies the number of archived logs to retain.
  • compress — enables log file compression (typically into .gz).
  • missingok — prevents errors if a log file is missing.
  • notifempty — skips rotation for empty files.
  • create — creates new logs with specified permissions.

4. Running logrotate

Logrotate usually runs automatically via cron. However, you can run it manually if you need to check the configuration or perform a rotation immediately:

sudo logrotate -f /etc/logrotate.conf

5. Verifying logrotate's operation

To ensure that logrotate is working correctly, you can check the latest entries in its service log:

sudo journalctl -u logrotate -n 10

Logs are taking up too much space on your server. How to fix it?

· 2 min read
Customer Care Engineer
info

Most log files are stored in the /var/log directory, but they are not limited to it. The principles described in this section apply to all *.log files in any directory on your server.

Logs are files that store information about server events: application and operating system activity, various errors, user requests to websites, and more. Over time, logs can take up a significant amount of disk space, especially under heavy load or if there are software errors.

One critical aspect of log files is that, in most cases, deleting them can cause issues for the program generating them — whether it’s a web server or even the operating system itself.

Additionally, logs often contain valuable diagnostic information that can help identify software issues on your server and prevent larger problems. Therefore, it’s important to handle them properly and carefully.


How to identify logs that can be cleaned

Use ncdu to locate large logs on the server. If a log file is unusually large, check its latest entries:

sudo tail /path/to/log

If there are no anomalies, check the beginning of the file to determine whether the log grew large simply due to age (pay attention to the date of the earliest entries):

sudo head /path/to/log

After this, you can proceed with cleaning the file.

info

If you’re unsure why the log file has grown so large, it’s better to save it and contact your hosting provider’s support team for clarification.


How to safely clean logs

The truncate command clears the contents of a file without deleting it:

sudo truncate -s 0 /var/log/nginx/error.log

Separately note the files that are logs, despite the lack of *.log extension:

  • /var/log/btmp
  • /var/log/syslog
  • /var/log/messeges
  • /var/log/secure
  • /var/log/maillog

These files can also be safely cleaned using the truncate command.

A special case is the log located in the /var/log/journal directory. You can find more details about working with it in separate article.   


How to prevent logs from growing too large

While analyzing logs, you may notice some of them have names like:

  • syslog.1
  • yoursite.access.log.1

These appear when log rotation is applied, for example, using the logrotate program. Old files can be deleted or compressed during rotation, saving disk space.

You can read more about configuring this mechanism in a separate article.

How to find and delete files that are "eating up" space on the server

· 2 min read
Customer Care Engineer

Running out of space on your server? This may cause the site and database to malfunction. To free up space, you need to identify the files taking up the most room and delete them. In this article, we’ll explain how to easily accomplish this using the ncdu utility and how to safely clean up logs.


Step 1: Installing and running ncdu

ncdu  is a handy tool for disk space analysis. It displays all folders and files sorted by size in an easy-to-use text interface.

To use this program, you’ll need to connect to your server via SSH.  

Installation

  • Debian/Ubuntu:
sudo apt update && sudo apt install ncdu
  • CentOS/AlmaLinux/Rocky Linux:
sudo yum install ncdu

Running disk analysis

  • To scan the root directory /, execute:
sudo ncdu -x /

The -x option in ncdu restricts the scan to a single file system, excluding mounted virtual directories (e.g., /proc, /dev, /sys) and any other volumes mounted via separate mount points (e.g., network or external drives).

  • To analyze a specific directory:
sudo ncdu /path/to/directory

For example, to scan only the logs directory, run:

sudo ncdu /var/log

Step 2: Analyzing and deleting unnecessary files

After running ncdu, you will see a list of files and folders sorted by size. Navigation is simple:

  • Up/Down arrow keys — move through the list.
  • Enter — navigate into a directory.
  • D — delete the selected file or folder.

Ncdu inctruction 1

danger

Be careful when deleting system files. Delete only those files that you are sure of.

When files are deleted in Linux, they are permanently removed! Recovery is only possible through backups, and only if available.

It is safer to create a list of files and directories taking up significant space (highlight rows in ncdu and copy them to a notepad on your local PC), then review each individually and delete them using the command line.

To delete a file, run:

sudo rm -f /path/to/file

To delete a directory:

sudo rm -rf /path/to/directory

  Here's a list of the major directories that tend to take up a lot of space:

  1. /var/www/ - directory with your sites

Often, the largest directories are upload and cache in the root directory of the website, containing user-uploaded files and the site cache, respectively. For example:

/var/www/user/data/www/yoursite.com/upload/

Files in these directories are relatively safe to delete. However, only you, as the administrator of your website, know which files in the upload directory are important and which are no longer needed. It is recommended to leave the directory itself intact to avoid errors. 

  1. /var/lib/mysql/

This is the directory containing your website databases. 

danger

Please do not delete anything from this directory!

If it is taking up an unusually large amount of space, contact your hosting provider for a deeper analysis of the issue. 

  1. /var/log/

This directory stores logs generated by software running on your server. Logs have specific characteristics, and their cleanup is covered in a separate article.


Step 3: Finalizing and verifying

After deleting unnecessary files, check how much space has been freed using the command:

df -h

How to change the MariaDB password for root and regular users

· 3 min read
Customer Care Engineer

Forgot your MariaDB root password? Without it, you won’t be able to manage users, databases, or perform critical configurations. In this article, you’ll learn not only how to quickly reset the MariaDB root password but also how to reset the password for regular users. 

info

The root user is the main administrator of the database. They have full access to all data and settings. If you lose this password, you will not be able to change some settings or execute commands.

All operations will be performed via the command line over SSH. You can find detailed instructions on how to connect to your server using SSH in this article

Before proceeding, check the contents of the /root/.my.cnf file. Often, it contains the current root password for accessing MariaDB

To test the connection, use the command:

mysql -u root -p 

Then, enter the password from the .my.cnf file. 

If the password doesn’t work, follow the instructions below. 


Resetting the password

info

In most commands below, the mysql command will be used instead of mariadb to interact with the MariaDB server. This is because, on some operating systems, such as RHEL-based distributions (RockyLinux, AlmaLinux, etc.), the mariadb command is unavailable. Instead, the mysql command is used for compatibility with MySQL.

Using the mysql command provides universal compatibility regardless of the distribution or implementation of the server.

Step 1: Stop MariaDB

To reset the password, first stop the MariaDB server. Enter the following command:

systemctl stop mariadb

 Step 2: Restart the server in safe mode

  • For Debian and Ubuntu:

Make sure the directory MariaDB will run from exists and has the correct owner:

mkdir -p /var/run/mysqld/ && chown -R mysql: /var/run/mysqld/

 Start the MariaDB server without access control:

mysqld_safe --skip-grant-tables --socket=/var/run/mysqld/mysqld.sock &

If the MariaDB server starts successfully, you will see a message similar to:

2024-11-28T23:50:19.298141Z mysqld_safe Starting mariadb daemon with databases from /var/lib/mysql

To continue working in the command line, press “Ctrl + C”. 

  • For CentOS/RockyLinux/AlmaLinux:

Start the MariaDB server without access control:

mysqld_safe --skip-grant-tables --socket=/var/lib/mysql/mysql.sock &

To continue working in the command line, press “Ctrl + C”.

Step 3: Connect to MariaDB

  • For Debian and Ubuntu:
mysql --socket=/var/run/mysqld/mysqld.sock
  • For CentOS/RockyLinux/AlmaLinux:
mysql --socket=/var/lib/mysql/mysql.sock

 Step 4: Reset the password

Execute the following commands sequentially:

FLUSH PRIVILEGES;

 For a local user:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

For a network user (if it exists):

ALTER USER 'root'@'%' IDENTIFIED BY 'NewPassword';

Then:

FLUSH PRIVILEGES;

Replace NewPassword with your desired new password.

info

'user'@'localhost' — refers to a local user connecting via socket or localhost. 'user'@'%' refers to a network user with access from any IP address.

You can set the same or different passwords for these users. If the network user doesn’t exist, the @'%' command will result in an error.

Exit MariaDB using the exit command or by pressing “Ctrl + D”. 

Step 5: Restart MariaDB

Stop the MariaDB server:

  • For Debian and Ubuntu:
mysqladmin shutdown --socket=/var/run/mysqld/mysqld.sock -p

Then, enter the previously set root password.

  • For CentOS/RockyLinux/AlmaLinux:
mysqladmin shutdown --socket=/var/lib/mysql/mysql.sock -p

Then, enter the previously set root password.

Start MariaDB in normal mode:

systemctl start mariadb

 How to reset the password for regular users

If you forget the password for a user other than root, the approach is similar:

  1. Connect to the MariaDB server as root:
mysql -u root -p

 Enter your MariaDB root password.

  1. Execute the command to change the password:

For a local user:

ALTER USER 'username'@'localhost' IDENTIFIED BY 'NewUserPassword';

For a network user (if it exists):

ALTER USER 'username'@'%' IDENTIFIED BY 'NewUserPassword';

Then:

FLUSH PRIVILEGES;

Replace username with the actual username and NewUserPassword with your desired new password.

Exit MariaDB using the exit command or by pressing “Ctrl + D”.

If necessary, you can list all users with the following query:

SELECT User, Host FROM mysql.user;

How to connect to MariaDB locally without entering a password

To avoid entering the password manually each time you connect to MariaDB from the command line on your server, you can save it in the /root/.my.cnf file. Open the file in a text editor:

nano /root/.my.cnf

Add the following lines:

[client]

user = root
password = YourRootPassword

Replace YourRootPassword with your actual root password.

Save the file by pressing Ctrl + O, then exit the text editor with Ctrl + X. 

For security purposes, set stricter permissions on the .my.cnf file:

chmod 600 /root/.my.cnf

After this, you can connect by simply running the command:

mysql -u root

How to change the MySQL password for root and regular users

· 3 min read
Customer Care Engineer

Forgot the MySQL root password? Don't worry, it happens even to experienced administrators. In this article, we’ll explain how to reset the MySQL root password for different versions: MySQL 5.7 and MySQL 8.0+. Additionally, we’ll cover how to reset the password for a regular database user. 

info

Root is the main database administrator. They have full access to all data and settings. If you lose this password, modifying certain settings and executing some commands will no longer be possible. 

All operations will be performed via the command line over SSH. You can find more detailed instructions on connecting to your server using this protocol in this article

Before proceeding, check the contents of the /root/.my.cnf file. Often, it contains the current root password for accessing MySQL

You can test the connection using the command:

mysql -u root -p 

Then, enter the password from the .my.cnf file. 

If the password doesn’t work, follow the instructions below.


How to reset root MySQL password

Step 1: Stop MySQL

To reset the password, you first need to stop the MySQL. Enter the following command:

  • For Debian and Ubuntu:
systemctl stop mysql
  • For CentOS/RockyLinux/AlmaLinux:
systemctl stop mysqld

Step 2: Restart the server in safe mode

  • For Debian and Ubuntu:

Make sure that the directory from which MySQL will be run exists and has the appropriate owner:

mkdir -p /var/run/mysqld/ && chown -R mysql: /var/run/mysqld/

 Start the MySQL server without access control:

mysqld_safe --skip-grant-tables --socket=/var/run/mysqld/mysqld.sock &

If MySQL starts correctly, you’ll see a message similar to:

2024-11-28T23:50:19.298141Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

To continue working in the command line, press “Ctrl + C”.

  • For CentOS/RockyLinux/AlmaLinux:
sudo -u mysql mysqld --skip-grant-tables --socket=/var/run/mysqld/mysqld.sock &

 Step 3: Connect to MySQL

 mysql --socket=/var/run/mysqld/mysqld.sock

 Step 4: Reset the password

  • For MySQL 5.7, execute the following commands sequentially:
FLUSH PRIVILEGES;

 For a local user:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

For a network user (if it exists):

ALTER USER 'root'@'%' IDENTIFIED BY 'NewPassword';

Then:

FLUSH PRIVILEGES;

Replace NewPassword with your desired new password.

info

'user'@'localhost' refers to a local user connecting via socket or localhost. 'user'@'%' refers to a network user with access from any IP address.

You can set the same or different passwords for these users. If the network user doesn’t exist, the @'%' command will result in an error.

Exit MySQL using the exit command or by pressing “Ctrl + D”.

  • For MySQL 8.0+, execute the following commands:
FLUSH PRIVILEGES;

 For a local user:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewPassword';

For a network user (if it exists):

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'NewPassword';

Then:

FLUSH PRIVILEGES;

Replace NewPassword with your desired new password.

Exit MySQL using the exit command or by pressing “Ctrl + D”.

Step 5: Restart MySQL

Stop MySQL:

mysqladmin shutdown --socket=/var/run/mysqld/mysqld.sock -p

Then, enter the previously set root password.

Start MySQL in normal mode:

  • For Debian and Ubuntu:
systemctl start mysql
  • For CentOS/RockyLinux/AlmaLinux:
systemctl start mysqld

 How to reset the password for regular users

If you forgot the password for a user other than root, the approach is similar:

  1. Connect to the MySQL server as root:
mysql -u root -p

 Enter your MySQL root password.

  1. Execute the command to change the password:
  • MySQL 5.7:

For a local user:

ALTER USER 'username'@'localhost' IDENTIFIED BY 'NewUserPassword';

For a network user (if it exists):

ALTER USER 'username'@'%' IDENTIFIED BY 'NewUserPassword';

Then:

FLUSH PRIVILEGES;

Replace username with the existing username and NewUserPassword with the new desired password.

Exit MySQL using the exit command or by pressing “Ctrl + D”.

  • MySQL 8.0+:

For a local user:

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewPassword';

For a network user (if it exists):

ALTER USER 'username'@'%' IDENTIFIED WITH mysql_native_password BY 'NewPassword';

Replace username with the existing username and NewUserPassword with the new desired password.

Then exit MySQL using the exit command or the “Ctrl + D” key combination.

If necessary, you can list all users with the following query:

SELECT User, Host FROM mysql.user;

 How to connect to MySQL locally without entering a password

To avoid entering the password manually every time you connect to MySQL from the command line on your server, you can save it in the /root/.my.cnf file. Open the file in a text editor:

nano /root/.my.cnf

Add the following lines:

[client]

user = root
password = YourRootPassword

Replace YourRootPassword with your actual root password.

Then save the file using the “Ctrl + O” key combination and exit the text editor with “Ctrl + X”.

For security, set stricter permissions on the .my.cnf file:

chmod 600 /root/.my.cnf

After this setup, you can connect by simply running the command:

mysql -u root

Working with TAR Archives in Linux Command Prompt

· 2 min read
Customer Care Engineer

The TAR format is extremely popular in the Linux world and is the de facto data archiving standard. It can’t compress files by itself but perfectly cooperates with such compression utilities as gzip or bzip2. Therefore, most archives packed with this format that you can find on the web will look as archive_name.tar.gz.

Before You Begin

In most cases, tar is installed by default. To be 100% sure, run the command to install this archiver:

For Debian and Ubuntu:

sudo apt update && sudo apt install tar

For CentOS and Rocky Linux/AlmaLinux:

sudo yum makecache && sudo yum install tar

How to Create a TAR Archive

Without compression:

tar -cvf archive.tar /file/path

Where:

  • -c — to create an archive
  • -v — show details in the terminal (you’ll find it useful if you want to see what’s going on)
  • -f — specify the name of the archive file

With additional compression (for example, gzip):

tar -czvf archive.tar.gz /file/path
  • -z — adds gzip compression.

The second command is preferable in most cases, since additional compression will save time for downloading or uploading a file from or to the server, and the archive will take up less drive space.

How to extract a TAR Archive

For gzip:

tar -xzvf archive.tar.gz

For bzip2:

tar -xjvf archive.tar.bz2

For a uncompressed archive:

tar -xvf archive.tar

Additional Useful Options

  • -t — view the archive contents without unpacking:
tar -tvf archive.tar

Shows a list of archive files in the console, but doesn’t unpack it.

  • -u — update files within the archive:
tar -uf archive.tar /path/to/new_files

Consider the following details when updating a file within the archive:

  • If the archive contains no new_file.txt, it will be added.
  • If the archive already contains a file of the same name, but its contents on the drive have changed, then this file will be updated to the latest version.

You can also use this command to update multiple files at once, for example:

tar -uf archive.tar /path/to/new_files/*.txt

This command will update all txt files in the archive and will add new ones if they haven’t been added before.

Working with RAR Archives in Linux Command Prompt

· 2 min read
Customer Care Engineer

The RAR format is famous for its high compression level, support for data recovery, and high tamper resistance, which made it quite popular in the Windows community. But yet, it’s less popular among Linux users and administrators than a number of other archives. However, you may need to be able to work with it on the server, so let’s take a look at the basic commands and options you’ll need to confidently work with RAR archives in a command prompt.

Before You Begin

Make sure that you have all the required packages installed.

For Debian and Ubuntu:

sudo apt update && sudo apt install rar unrar

For CentOS and Rocky Linux/AlmaLinux:

# Add an additional EPEL repository, since the system ones contain no rar
sudo yum install epel-release
sudo yum makecache && sudo yum install rar unrar

How to Create a RAR Archive

Use the following command to create an archive:

rar a archive.rar /directory/path/

For example:

rar a backup.rar /var/www/html/

How to extract a RAR Archive

To extract the archive in the current directory, use the following command:

unrar x archive.rar

To extract the archive to a directory other than the current one, you need to specify the path to it at the end. For example:

unrar x backup.rar /home/user/backup/

Additional Useful Options

  • -l — show a list of files within the archive without extracting it:
unrar l archive.rar
  • -u — update files within the archive:
rar u archive.rar /path/to/new_files

Consider the following details when updating a file within the archive:

  • If the archive contains no new_file.txt, it will be added.
  • If the archive already contains a file of the same name, but its contents on the drive have changed, then this file will be updated to the latest version.

You can also use this command to update multiple files at once, for example:

rar u archive.rar *.txt

This command will update all txt files in the archive and will add new ones if they haven’t been added before.

  • -p — set a password for the archive:
rar a -p archive.rar /file/path

Working with ZIP Archives in Linux Command Prompt

· 2 min read
Customer Care Engineer

ZIP is one of the most popular archiving formats. Unlike a home PC that allows you to work with such archives in a convenient graphical interface, most servers don’t provide such an opportunity. So, be sure to know the basic commands to perform typical tasks via a command prompt.

Before You Begin

Make sure that you have all the required packages installed.

For Debian and Ubuntu:

sudo apt update && sudo apt install zip unzip

For CentOS and Rocky Linux/AlmaLinux:

sudo yum makecache && sudo yum install zip unzip

How to Create a ZIP Archive

Use the following command to create an archive:

zip -r archive_name.zip /directory/path/

The -r is used to recursively add all files and subdirectories to the archive.

How to extract a ZIP Archive

To extract zip archive you can use the following command:

unzip archive.zip

The contents will be unzipped in the current directory by default. If you want to unzip the archive into another place, use the -d option.

For example:

unzip backup.zip -d /home/user/backup/

Additional Useful Options

  • -l — show a list of files within the archive without unzipping it:
unzip -l archive.zip
  • -u — update a file within the archive:
zip -u archive.zip new_file.txt

Consider the following details when updating a file within the archive:

  • If the archive contains no new_file.txt, it will be added.
  • If the archive already contains a file of the same name, but its contents on the drive have changed, then this file will be updated to the latest version.

You can also use this command to update multiple files at once, for example:

zip -u archive.zip *.txt

This command will update all .txt files in the archive and will add new ones if they haven’t been added before.

  • -e — set a password for the archive:
zip -e archive.zip /file/path

How to use FTP and SFTP server

· 3 min read
Customer Care Engineer

How to use an FTP server?

When working with FTP and SFTP servers, it is important to understand how to properly connect and protect your data. In this guide, we will look at step-by-step instructions on how to set up connections to FTP and SFTP servers, and learn how to use SSH keys to increase connection security.

Using a special FTP client is the best way to simplify your life when working with FTP. The user-friendly interface will allow you to send and receive data from your computer to the server. The most popular FTP clients are:

  • WinSCP for Windows

  • Transmit

  • Cyberduck

  • Filezilla

Let's consider connecting to the server using Filezilla on Windows.

  1. Open the site manager (File – Site manager). Click the "New site" button.

27-08-ftp-sftp-1.png

  1. Enter the connection name and login credentials

  2. Select the encryption mode "Use explicit FTP over TLS if available"

  3. Click "Connect"

  4. Now you can work with the FTP server and upload the first data to it

How do you use an SFTP server?

  1. Open the site manager (File – Site manager). Click the "New site" button.

27-08-ftp-sftp-1.png

  1. Enter the connection name and access data

  2. Select the SFTP protocol from the General tab

  3. Click "Connect"

  4. Now you can work with the SFTP server and upload the first data to it

We recommend that you always choose the SFTP protocol for your work. All FTP functions are available here and SSH protects your data.

How to use SSH keys with SFTP

SSH keys allow you to authenticate without a password. Keys are a set of hundreds of different characters, including upper and lower-case Latin characters and special characters. The total length is often between 1024 and 4096 bits. Authentication requires two SSH keys, one public and one private.

  • Public keys are available to everyone. It is used to encrypt data when accessing the server. Simply put, it is a set of characters that we use to encrypt information.

  • The private key is the key to the lock. It decrypts the data. You need to be much more careful with it: keep it safe and do not give it to second parties.

In the Edit menu, go to Settings. Under Connection › SFTP, you can add your existing SSH private key. In Site Manager select Interactive logon type to connect to the SFTP site.

27-08-ftp-sftp-2.png

How to generate SSH keys

You can create public and private keys using the PuTTYgen. PuTTY stores keys in its own format in .ppk files. To create a new key pair, select the type of key to generate from the bottom of the screen. RSA with 2048 bits is the most popular type.

27-08-ftp-sftp-3.png

Then click Generate, and start moving the mouse within the Window. Putty uses mouse movements to achieve randomness. When complete, the public key should appear in the Window. Save the key as a .ppk file.

27-08-ftp-sftp-4.png

Installing the public key

Access to an account is granted by adding the public key to a ~/.ssh/authorized_keys file on the server.

To add the public key, log into the server, edit the authorized_keys file, and cut and paste the public key to the authorized_keys file. Save the file. Add a private key (.ppk) file to PuTTY. Then test if login works.

It is recommended that all SSH keys be regenerated and changed periodically.

Conclusion

Using FTP clients and following our instructions, you can easily manage files on the server. Do not forget about the importance of SSH keys to protect your data, update them regularly and follow security rules to minimize risks when working with remote servers.

FTP is an outdated technology

· 3 min read
Customer Care Engineer

The FTP protocol is prevalent because of its simplicity and availability. However, it needs to be updated and more secure. Here we tell you why you should give it up.

Problems in the FTP architecture

In general, FTP does not have the level of security required for the modern Internet, and the overall design of the protocol is unsuitable for the modern Internet. It was developed in the 1970s, when the requirements for technology were very different from those of today. Let's understand a bit more about its design.

FTP operates on two channels: command channel and data channel. The data channel has two transmission modes - active and passive.

The difference between active and passive mode is on whose side the establishment of a data connection is initiated.

In passive mode, the server opens a random port from the dynamic range on its side and informs the client about it; the client initiates a TCP connection to this port.

In active mode, a random port from the dynamic range is opened from the client side and it is the server that initiates the TCP connection. In most cases, this mode is not suitable due to the peculiarities of address translation (NAT) settings on the part of home Internet providers, which will not allow to establishment of an incoming connection with the client device.

Disadvantages of FTP

To upload any file through FTP client and server have to exchange a very large number of messages. This leads to the loss of a lot of time and resources.

Delays occur not only at the FTP level but also at the TCP level because transferring each individual file requires opening a new TCP connection. If you need to transfer more than "a few" files, this is extremely inconvenient.

Another problem is that it is impossible to check if the transfer was completed successfully. The server does not even know the size of the file. If something fails to load during the transfer, neither the client nor the server will know about it.

FTP has other limitations that make working with it extremely inconvenient. For example, you cannot delete directories. You have to delete all files individually, and then delete the directory itself.

In addition, FTP does not support special characters. There are some ways to still use them, but these temporary solutions will inevitably cause problems at work.

There are big privacy issues as well. In FTP, credentials are transmitted unencrypted. The username and password are transmitted in plain text that can be read by anyone capable of intercepting network traffic.

The data itself is not encrypted either. Therefore, it is highly undesirable to send any sensitive information via FTP.

In the case when you still need to use the FTP protocol must pay special attention to the protection of the connection to the Internet. This is a topic for a separate article, but at least it is better not to use public wi-fi networks and use a VPN, preferably on your own server.

A secure alternative to FTP - SFTP

Of course, there are several alternatives. Let's talk about the best option among them. This is SFTP (SSH File Transfer Protocol). Its most obvious advantage is security and data encryption.

Other benefits of SFTP include:

  • pause and resume data transfer,

  • complete stop of file transfer,

  • the ability to execute basic administrative commands,

  • metadata transfer.

By using SSH within the SFTP protocol, you get these benefits:

  • Client and Server Authentication. SSH authenticates based on a public and private key pair. This allows you to accurately determine that the client requesting connection to the server is legitimate.

  • Data encryption. RSA, DSA, and other types are available.

  • Data transmission through a single port reduces the likelihood of an MITM attack.

So, the only reason FTP is still popular and used is force of habit. But that habit should be gotten rid of. And switch to SFTP.