# Sys

Web, Dev, Linux, Apache, Nginx, MySQL, webhost, webserver, sysadmin

## How to transfer files using scp command

For each of the following methods, make sure you have the right credentials to each remote server you are working. You need the right pair of username and password of each machine for a successful transfer.

## How to FTP to and from a server that is accessible only via authentication-key pair

Scenario
Your backend is accessible only through ssh key-pairing but you have the need to use an FTP program like FileZilla to transfer a file from or to a local machine.

Temporarily disable the ssh only access
From the command line:

1. sudo nano /etc/ssh/sshd_config
2. Set PasswordAuthentication to yes
3. sudo service sshd restart

## How to Manually Renew Let's Encrypt SSL Certificate via Command Line

Certbot failed to renew certificate to all domains hosted in a particular server. While most of the servers shoot the bot to acquire the certificate, it bug me why some didn't when they have the same setup. I guess because a domain or two in those failed servers are using premium SSL, but I am not sure honestly.

## Install Certbot to Auto-Renew SSL Certificates Issued by Let's Encrypt

Certbot will let you manage your SSL certificates, ensuring that your server will automatically renew Let's Encrypt without you doing it by hand.

## Create a Database and a User with Full Privileges

Create a database named database_name and enter your root database password
mysql -u root -p -e "CREATE DATABASE database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";

## Create an Apache Virtual Host for a Drupal 9 Site

Create a Drupal site directory. For this setup, websites are at /var/www/
cd /var/www
mkdir example.com

## Install Let's Encrypt and Create an SSL Certificate

Note: Use Certbot for easy management of Let's Encrypt SSL certificates.

## Give Apache a Write Permission

Code:
chown -R www-data:www-data /path/to/folder/

## Migrating a Simple Drupal-Site via SSH

Note that this is a personal workflow of mine and not a tutorial.  Commands may vary according to your setup.