Skip to content

Blog

Ubuntu dependency resolution and installation

1. Ubuntu platform package management tool apt/dpkg

Section titled “1. Ubuntu platform package management tool apt/dpkg”

dpkg is used to install .deb files, but it does not resolve module dependencies and does not care about the software in Ubuntu’s software warehouse. apt will resolve and install module dependencies and consult the software repository.

2. Check package dependencies in Ubuntuapt-cache depends XXX --recurse

Section titled “2. Check package dependencies in Ubuntuapt-cache depends XXX --recurse”

Check which packages XXX depends on, –recurse means recursive search apt-cache rdepends XXX Check which packages depend on XXX

3. Download the .deb fileapt-get install --no-recommends -d XXX

Section titled “3. Download the .deb fileapt-get install --no-recommends -d XXX”

The download file is located in the /var/cache/apt/archives/ directory apt-get download XXX The download file is the current directory

apt install *.deb
dpkg -i *.deb

Command differences reference Ubuntu platform package management tool apt/dpkg

5. sources.list file- File directory/etc/apt/sources.list- In the default sources.list file, the default configuration is the source of ubuntu.com

Section titled “5. sources.list file- File directory/etc/apt/sources.list- In the default sources.list file, the default configuration is the source of ubuntu.com”

Using-FIDO2-as-SSH-Authentication

FIDO2 is available in OpenSSH 8.2 version, which is much more convenience then OpenPGP.

  • A Yubikey Device, or other device support FIDO2.
ssh-keygen -t ed25519-sk -O resident -f ~/.ssh/id_ ed25519-sk
ssh-add -K
ssh-add -L

[1].https://blog.bloade.com/2022/03/20/%E4%B8%BAopenssh%E9%85%8D%E7%BD%AEfido2%E8%AE%A4%E8%AF%81/

[2].SSH-Configuration

Let's Encrypt with Certbot

This post is going to introducing how to encrypt your website using HTTPS, with Certbot.

All the steps based on CentOS/RHEL(Red Hat Enterprise Linux).

  • OS: CentOS/RHEL
  • Packages: certbot (Optional: certbot-dns-cloudflare)
  • HostName: example.com

Install certbot on your system with dnf package manager:

sudo dnf install python3-certbot

If you wish to use dns-01 challenge, we take cloudflare as an example, you should install certbot-dns-cloudflare plugin:

sudo dnf install python3-certbot-dns-cloudflare

Make sure you have set your hostname to your host ip.

Allow port 80 on your host:

sudo firewall-cmd --add-port=80/tcp

(3). Issuing SSL Certificates with Certbot

Section titled “(3). Issuing SSL Certificates with Certbot”

Using the following command to issue a SSL certificate from Let’s Encrypt

sudo certbot certonly -d example.com

The private key and public key will be stored in folder /etc/letsencrypt/live/example.com/.

(4). Config Your Site with SSL Certificates

Section titled “(4). Config Your Site with SSL Certificates”

This is not the keypoint of this post, configuration should be varies depending on the web server used. Please refer to other resources online.

Optional-1. Config Nginx with Certbot automatically

Section titled “Optional-1. Config Nginx with Certbot automatically”

If you are using Nginx, it would be convenient by using --nginx parameter, replace the command in step(3):

sudo certbot certonly -d example.com --nginx

Then all configurations will be done in nginx file located in /etc/nginx/conf.d/example.com.conf

The dns_cloudflare plugin automates the process of completing a dns-01 challenge (DNS01) by creating, and subsequently removing, TXT records using the Cloudflare API.

The following command will do this operation:

sudo certbot certonly \
--dns-cloudflare \
--dns-cloudflare-credentials ~/PATH_TO_CF_KEY/cf_key.txt \

In this section, cf_key.txt contains the API TOKEN or Global API Key from Cloudflare, here is the example of this two structure:

# Cloudflare API token used by Certbot
dns_cloudflare_api_token = 0123456789abcdef0123456789abcdef01234567
# Cloudflare API credentials used by Certbot
dns_cloudflare_email = cloudflare@example.com
dns_cloudflare_api_token = 0123456789abcdef0123456789abcdef01234

[1].https://certbot-dns-cloudflare.readthedocs.io/en/stable/

[2].https://developers.cloudflare.com/fundamentals/api/get-started/create-token/

[3].https://developers.cloudflare.com/fundamentals/api/get-started/keys/

[4]. Reverse-Proxy-with-Nginx-on-RHEL

Git Configuration

In this article, we introduces git configuration for basic use.

Remarkablely, configurations for symbolic links are supported on Windows with extra settings.

The purpose we have to point out, is the git compatibility on both Windows and Unix like system.

  • Config User Name
git config --global user.name 'NAME'
  • Config User Email
git config --global user.email 'EMAIL@EXAMPLE.COM'
  • Config signingkey
git config --global user.signingkey XXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXX: Personal gpg private key in LONG or SHORT format

  • Config GPG
git config --global gpg.program C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
  • Config Commit and Tag
git config --global commit.gpgsign true
git config --global tag.gpgsign true

3. Config Git on Windows for compatibility with Unix like system

Section titled “3. Config Git on Windows for compatibility with Unix like system”
  • Config filemode authority
git config --global core.filemode false
  • Config CRLF and LF auto change
git config --global core.autocrlf true
  • Config case-sensitive
git config --global core.ignorecase false
  • Config symlinks
git config --global core.symlinks true
  • Enable Develop Mode on Windows10 and later
  • Enable symlinks on installing git on Windows
  • Group Policy:
    • Navigate to create user permission to create symbolic links:
    • Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Create symbolic links
    • type the user name and click “Check Names” then OK.
git config --global filter.lfs.smudge "git-lfs smudge --skip -- %f"
git config --global filter.lfs.process "git-lfs filter-process --skip"
[core]
symlinks = true
autocrlf = true
filemode = false
ignorecase = false
[user]
name = User Name
email = Username@example.com
signingkey = XXXXXXXXXXXXXXXX
[commit]
gpgsign = true
[tag]
gpgsign = true
[gpg]
program = C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
[filter "lfs"]
smudge = git-lfs smudge --skip -- %f
process = git-lfs filter-process --skip
mklink [[/d] | [/h] | [/j]] <link> <target>

/d Creates a directory symbolic link. By default, this command creates a file symbolic link.

/h Creates a hard link instead of a symbolic link.

/j Creates a Directory Junction.

<link> Specifies the name of the symbolic link being created.

<target> Specifies the path (relative or absolute) that the new symbolic link refers to.

/? Displays help at the command prompt.

git tag XXXX
git tag -d <tagname>
git push origin --delete <tagname>
git push origin <tagname>
git branch -d <branchname>
git push origin --delete <branchname>

[1]. https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work

[2]. https://github.com/git-for-windows/git/wiki/Symbolic-Links

[3]. https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink

[4]. 从一个git仓库提交代码到另一个仓库

[5]. GitLab-CI-CD-Push-to-Repository

LogRotate

LogRotate is a log management tool, which enables log files’ cutting, deleting and creating, and triggered by crontab.

The default config file located/etc/logrotate.conf In default config file, the config folder/etc/logrotate.dis included by default. Which means, config files added in this folder will be executed by logrotate process.

/var/log/***.log { # The target log file
LOG_CONFIG_PARAMETERS # The parameters for logrotate
}
  • daily: The cutting cycle is daily
  • weekly: The cutting cycle is weekly
  • monthly: The cutting cycle is monthly
  • yearly: The cutting cycle is every year
  • size 50M
  • rotate 1
  • maxage 1

(5). Do not dump files with specified extensions

Section titled “(5). Do not dump files with specified extensions”
  • tabooext [+] list
  • missingok
  • copytruncate/nocopytruncate
  • create mode owner group
  • nocreate
  • nocompress
  • compress
  • delaycompress
  • nodelaycompress

(11). Execute before all other instructions are completed

Section titled “(11). Execute before all other instructions are completed”
  • prerotate
  • endscript

(12). Execute after all other instructions are completed

Section titled “(12). Execute after all other instructions are completed”
  • postrotate
  • endscript
  • sharedscripts

(14). The error message is sent to the specified email address

Section titled “(14). The error message is sent to the specified email address”
  • errors address

(15). Send the dumped log file to the specified E-mail address

Section titled “(15). Send the dumped log file to the specified E-mail address”
  • mail address
  • nomail
  • ifempty
  • notifempty
  • olddir directory
  • noolddir
  • dateext
  • dateformat
  • dateyesterday
  • extension

[1]. https://blog.csdn.net/xiaojin21cen/article/details/122309230

[2]. https://linux.die.net/man/8/logrotate