跳转到内容

博客

Ubuntu依赖解析和安装

dpkg是用来安装.deb文件,但不会解决模块的依赖关系,且不会关心ubuntu的软件仓库内的软件

apt会解决和安装模块的依赖问题,并会咨询软件仓库

apt-cache depends XXX --recurse

查看XXX依赖哪些包, –recurse表示递归查找

apt-cache rdepends XXX

查看哪些包依赖于XXX

apt-get install --no-recommends -d XXX

下载文件位于/var/cache/apt/archives/ 目录下

apt-get download XXX

下载文件为当先目录

apt install *.deb
dpkg -i *.deb

命令区别参考 Ubuntu平台包管理工具apt/dpkg

  • 文件目录/etc/apt/sources.list
  • 默认的sources.list文件中,默认配置为ubuntu.com的源

使用 FIDO2 作为 SSH 身份验证

让我们用 Certbot 加密

一、简介这篇文章将介绍如何使用 HTTPS 和 [Certbot][certbot] 来加密您的网站。

Section titled “一、简介这篇文章将介绍如何使用 HTTPS 和 [Certbot][certbot] 来加密您的网站。”

所有步骤基于CentOS/RHEL(Red Hat Enterprise Linux)。

2. 环境要求- 操作系统:CentOS/RHEL- 软件包:certbot(可选:certbot-dns-cloudflare)- 主机名:example.com

Section titled “2. 环境要求- 操作系统:CentOS/RHEL- 软件包:certbot(可选:certbot-dns-cloudflare)- 主机名:example.com”

3.安装Certbot使用 dnf 包管理器在您的系统上安装 certbot:

Section titled “3.安装Certbot使用 dnf 包管理器在您的系统上安装 certbot:”
sudo dnf install python3-certbot

如果您想使用 dns-01 挑战,我们以cloudflare为例,您应该安装certbot-dns-cloudflare插件:

sudo dnf install python3-certbot-dns-cloudflare

确保您已将主机名设置为主机 IP。

(2)。配置防火墙允许主机上的端口80:

Section titled “(2)。配置防火墙允许主机上的端口80:”
sudo firewall-cmd --add-port=80/tcp

(3)。使用 Certbot 颁发 SSL 证书使用以下命令从[Let’s Encrypt][letEnc]颁发SSL证书

Section titled “(3)。使用 Certbot 颁发 SSL 证书使用以下命令从[Let’s Encrypt][letEnc]颁发SSL证书”
sudo certbot certonly -d example.com

私钥和公钥将存储在文件夹/etc/letsencrypt/live/example.com/中。

(4)。使用 SSL 证书配置您的站点这不是本文的重点,配置应根据所使用的 Web 服务器而有所不同。请参阅在线其他资源。

Section titled “(4)。使用 SSL 证书配置您的站点这不是本文的重点,配置应根据所使用的 Web 服务器而有所不同。请参阅在线其他资源。”

可选-1。自动使用 Certbot 配置 Nginx如果您使用[Nginx][nginx],使用--nginx参数会很方便,替换*step(3)*中的命令:

Section titled “可选-1。自动使用 Certbot 配置 Nginx如果您使用[Nginx][nginx],使用--nginx参数会很方便,替换*step(3)*中的命令:”
sudo certbot certonly -d example.com --nginx

然后所有配置将在位于/etc/nginx/conf.d/example.com.conf的 nginx 文件中完成

可选-2。dns-01的问题dns_cloudflare插件通过使用 Cloudflare API 创建并随后删除 TXT 记录,自动完成dns-01挑战 (DNS01) 的过程。

Section titled “可选-2。dns-01的问题dns_cloudflare插件通过使用 Cloudflare API 创建并随后删除 TXT 记录,自动完成dns-01挑战 (DNS01) 的过程。”

以下命令将执行此操作:

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

在本节中,cf_key.txt包含来自 Cloudflare 的 [API TOKEN][API] 或 [Global API Key][APIKEY],以下是这两个结构的示例:

# 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

[2].https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ [3].https://developers.cloudflare.com/fundamentals/api/get-started/keys/ [certbot]:https://certbot.eff.org [letEnc]:https://letsencrypt.org/ [nginx]:https://www.nginx.com [API]:https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ [APIKEY]:https://developers.cloudflare.com/fundamentals/api/get-started/keys/ [4]. 使用 RHEL 上的 Nginx 进行反向代理

Git 配置

本文介绍 Git 的基础配置。

对于符号链接,Windows 需要额外设置才能获得更好的兼容性。

这里重点关注 Git 在 Windows 与 Unix-like 系统之间的兼容性。

  • 配置用户名
git config --global user.name 'NAME'
  • 配置用户邮箱
git config --global user.email 'EMAIL@EXAMPLE.COM'
  • 配置 signing key
git config --global user.signingkey XXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXX:个人 GPG 私钥的 LONG 或 SHORT 格式。

  • 配置 GPG 程序
git config --global gpg.program C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
  • 配置 Commit 和 Tag 签名
git config --global commit.gpgsign true
git config --global tag.gpgsign true

3. 在 Windows 上配置 Git,以兼容 Unix-like 系统

Section titled “3. 在 Windows 上配置 Git,以兼容 Unix-like 系统”
  • 配置 filemode 权限
git config --global core.filemode false
  • 配置 CRLF 和 LF 自动转换
git config --global core.autocrlf true
  • 配置大小写敏感
git config --global core.ignorecase false
  • 配置符号链接
git config --global core.symlinks true
  • 在 Windows 10 及以上版本中启用开发者模式。
  • 安装 Git for Windows 时启用 symlinks。
  • 组策略:
    • 进入创建符号链接权限设置:
    • Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Create symbolic links
    • 输入用户名,点击 “Check Names”,然后确认。
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 manage 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.d is 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: 切割周期为 每天
  • weekly: 切割周期为 每周
  • monthly: 切割周期为 每月
  • yearly: 切割周期为 每年
  • size 50M
  • rotate 1
  • maxage 1
  • tabooext [+] list
  • missingok
  • copytruncate/nocopytruncate
  • create mode owner group
  • nocreate
  • nocompress
  • compress
  • delaycompress
  • nodelaycompress

(11). 在所有其它指令完成前执行

Section titled “(11). 在所有其它指令完成前执行”
  • prerotate
  • endscript

(12). 在所有其它指令完成后执行

Section titled “(12). 在所有其它指令完成后执行”
  • postrotate
  • endscript
  • sharedscripts

(14). 错误信息发送到指定的Email地址

Section titled “(14). 错误信息发送到指定的Email地址”
  • errors address

(15). 转储的日志文件发送到指定的E-mail地址

Section titled “(15). 转储的日志文件发送到指定的E-mail地址”
  • 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