Ubuntu Server 设置全局代理脚本

新建脚本文件

nano setproxy.sh

输入以下内容

#!/bin/bash

# 代理服务器地址和端口,根据实际情况进行修改
HTTP_PROXY_SERVER="http://172.16.44.88:10802"
HTTPS_PROXY_SERVER="$HTTP_PROXY_SERVER"
NO_PROXY_SERVER="localhost,127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local"
#全局代理
env_file="/etc/environment"
#全局用户代理
profile="/etc/profile.d/99proxy.sh"
#apt代理
apt_proxy="/etc/apt/apt.conf.d/99proxy"
# microk8s代理
microk8s_container_env="/var/snap/microk8s/current/args/containerd-env"

# 检查脚本是否以root权限运行
if [ "$(id -u)" != "0" ]; then
   echo "该脚本需要root权限来修改 $env_file"
   exit 1
fi

# 检查传入的参数
if [ "$1" == "on" ]; then
    # 添加代理配置
    echo "添加代理配置..."
阅读全文

Ubuntu Server Docker 安装与代理设置

参考 https://docs.docker.com/engine/install/ubuntu/

安装 docker apt key

install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc

添加 docker 源

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list
阅读全文

Ubuntu Server 启用 root 账户

在安装 Ubuntu Server 时无法启用 root 账户,只能创建一个非 root 账户。
在安装后如何启用 root 账户?

#重设root账户密码
sudo -i passwd root

#用root账户登录
su - root

#安装ssh服务
apt install ssh
systemctl enable ssh

#修改sshd配置,允许root用户用密码登录
nano /etc/ssh/sshd_config.d/sshd.conf

#允许root用户登录
PermitRootLogin yes
#允许使用密码登录
PasswordAuthentication yes

#可选,删除装系统时配置的用户及文件
deluser --remove-home <username#改中国时区
timedatectl set-timezone Asia/Shanghai

重启 ssh 服务生效

阅读全文