How To Set Up vsftpd (FTP server) On Ubuntu

FTP (File Transfer Protocol) is a network protocol that is used for transferring a file between computers. FTP is still used to support legacy applications and workflows with very specific needs. If you have a choice of protocol, consider modern options that are more efficient, secure, and convenient for delivering files like SFTP (Secure File Transfer Protocol).

vsftpd, very secure FTP daemon, is an FTP server for many Unix-like systems, including Linux, and is often the default FTP server for many Linux distributions as well. vsftpd is beneficial for optimizing security, performance, and stability. It also provides strong protection against security problems found in other FTP servers.

Read more: How To Set Up vsftpd (FTP server) On Ubuntu

In this tutorial, we will try to install and configure vsftpd to our server. And here’s the step to do that:

1. Installing vsftpd

Update your package list first:

sudo apt update

Next, install the vsftpd daemon:

sudo apt install vsftpd

And now vsftpd is already installed on your server.

2. Opening the Firewall

First, check the firewall status to see if it’s enabled. If it is, then you’ll make adjustments to ensure that FTP traffic is permitted so firewall rules don’t block our FTP requests.

sudo ufw status

You should see output like this, if it states that the status is active, then our server firewall is active and we need to add additional config:

Start by opening ports 2021, and 990 so they’re ready when you enable TLS:

sudo ufw allow 20,21,990/tcp

Next, open ports 40000-50000 for the range of passive ports you will be setting in the configuration file:

sudo ufw allow 40000:50000/tcp

Check the status of your firewall again, and it should add more additional configs like this:

3. Configure vsftpd Configuration

Open up the file at /etc/vsftpd.conf in your favorite text editor (vim, nano, …), and make sure the following lines are uncommented:

local_enable=YES

local_enable allows system-defined users in the /etc/passwd file to log in through vsftpd.

write_enable=YES

write_enable allows changes to the filesystem through FTP, such as uploading.

ascii_upload_enable=YES
ascii_download_enable=YES

ascii_upload_enable and ascii_download_enable tell vsftpd to disable ascii mangling. It’s a horrible feature of the FTP protocol that basically replaces line endings regardless of whether or not the FTP server is running on a Windows or Unix machine.

chroot_local_user=YES

chroot is shorthand for change root and will basically enable an environment that prevents the user from leaving its home directory.

4. Add New User

Although we can use system-defined users to log in through vsftpd, let’s create our own user to access the vsftpd service.

Run this command to create a new user:

adduser ftpuser

This will create a user named ftpuser, you will be asked some basic questions and also be asked to set up a password for that user.

And now we can use vsftpd service for our server.

How To Install MySQL on Ubuntu

MySQL is one of the most used RDBMS (Relational Database Management System) that used in the world. So learning to use this will bring us a great skill that can be used almost everywhere.

In this tutorial, we will learn how to install MySQL on our own server. So let’s start.

1. Install MySQL to Our Server

On Ubuntu, we can install MySQL server using APT package repository.

To install it, we need to update the server’s package index first with this command:

sudo apt update

Then install the mysql-server package:

sudo apt install mysql-server

Ensure that the server is running using these commands:

sudo systemctl start mysql.service
sudo systemctl enable mysql.service

These commands will install, start, and enable MySQL on server start, but will not prompt you to set a password or make any other configuration changes. Because this leaves your installation of MySQL insecure, we will address this next.

2. Configuring MySQL

For fresh installations of MySQL, you’ll want to run the database management system’s included security script. This script changes some of the less secure default options for things like disallowing remote root logins and removing sample users.

Run the security script with this command:

sudo mysql_secure_installation

This will take you through a series of prompts where you can make some changes to your MySQL installation’s security options. The first prompt will ask whether you’d like to set up the Validate Password Plugin, which can be used to test the password strength of new MySQL users before deeming them valid.

If you elect to set up the Validate Password Plugin, any MySQL user you create that authenticates with a password will be required to have a password that satisfies the policy you select:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
 2

Regardless of whether you choose to set up the Validate Password Plugin, the next prompt will be to set a password for the MySQL root user. Enter and then confirm a secure password of your choice:

Please set the password for root here.


New password:

Re-enter new password:

If you use the Validate Password Plugin, you’ll receive feedback on the strength of your new password. Then the script will ask if you want to continue with the password you just entered or if you want to enter a new one. Assuming you’re satisfied with the strength of the password you just entered, enter Y to continue the script:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y

From there, you can press Y and then ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MySQL immediately respects the changes you have made.

3. Creating a Dedicated MySQL User and Granting Privileges

Upon installation, MySQL creates a root user account which you can use to manage your database. This user has full privileges over the MySQL server, meaning it has complete control over every database, table, user, and so on. Because of this, it’s best to avoid using this account outside of administrative functions. This step outlines how to use the root MySQL user to create a new user account and grant it privileges.

In Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is set to authenticate using the auth_socket plugin by default rather than with a password. This plugin requires that the name of the operating system user that invokes the MySQL client matches the name of the MySQL user specified in the command, so you must invoke mysql with sudo privileges to gain access to the root MySQL user:

sudo mysql

 If you installed MySQL with another tutorial and enabled password authentication for root, you will need to use a different command to access the MySQL shell. The following will run your MySQL client with regular user privileges, and you will only gain administrator privileges within the database by authenticating:

mysql -u root -p

Run the following command to create a user that authenticates with a password. Be sure to change jack to your preferred username and password to a strong password of your choosing:

CREATE USER 'jack'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

After creating your new user, you can grant them the appropriate privileges. The general syntax for granting user privileges is as follows:

GRANT PRIVILEGE ON database.table TO 'username'@'host';

The PRIVILEGE value in this example syntax defines what actions the user is allowed to perform on the specified database and table. You can grant multiple privileges to the same user in one command by separating each with a comma. You can also grant a user privileges globally by entering asterisks (*) in place of the database and table names. In SQL, asterisks are special characters used to represent “all” databases or tables.

Following this, it’s good practice to run the FLUSH PRIVILEGES command. This will free up any memory that the server cached as a result of the preceding CREATE USER and GRANT statements:

FLUSH PRIVILEGES;

Then you can exit the MySQL client:

exit

In the future, to log in as your new MySQL user, you’d use a command like the following:

mysql -u jack-p

And, you’ve already succeeded in installing MySQL to your own server.

Web Scraping with Python in Indonesian E-Commerce (Tokopedia)

In 2006, British mathematician and Tesco marketing mastermind Clive Humby shouted from the rooftops, “Data is the new oil”. And today we can see data has become a powerful weapon that can influence the direction of the world. It can decide the next action that needs to be taken in a business, increase goods selling by providing the product related to the customer’s taste, create good Artificial Intelligence to minimize human work, etc.

In this article, we will study how to get data from an existing website, this action is usually called web scraping. For this one, we will use Tokopedia, an Indonesian E-Commerce, as a study case.

Read More

Alternative Way To Install Upwork Desktop App For Manjaro(Arch Linux)

A few days ago, I wanted to install the Upwork desktop application to my Manjaro OS. Before this, I succeeded in installing the Upwork desktop application on my Windows 10 OS. But when I tried to install the application to my Manjaro OS, there was an error when the installation process tried to fetch the binary from the AUR (Archlinux User Repository). I already tried to check my connection, VPN, and tried some solutions from the internet but they were not helpful at all.

Read More