清华源

cp -a /etc/apt/sources.list /etc/apt/sources.listbak

cat > /etc/apt/sources.list <<EOF
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
EOF

apt-get update

安装常用软件

apt-get install -y vim curl wget git zsh  gcc make automake openssh-server 

开启ssh

ssh-keygen -A

sed -i 's/#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
systemctl   restart ssh

安装Go

export goversion="1.23.3"
wget https://go.dev/dl/go${goversion}.linux-amd64.tar.gz
tar zxf go${goversion}.linux-amd64.tar.gz 
mkdir /usr/local/go
mv go  /usr/local/go/$goversion
rm -rf go go${goversion}.linux-amd64.tar.gz 

安装Docker

install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

安装oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-completions.git ~/.oh-my-zsh/custom/plugins/zsh-completions

生成私钥

ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

环境变量设置

cat > ~/.zshrc << EOF
export ZSH="\$HOME/.oh-my-zsh"
ZSH_THEME="ys"
plugins=(git docker docker-compose zsh-completions zsh-autosuggestions zsh-syntax-highlighting)
source \$ZSH/oh-my-zsh.sh
export GOVERSION=1.23 # Go 版本设置
export GO_INSTALL_DIR=/usr/local/go # Go 安装目录
export GOROOT=\$GO_INSTALL_DIR/\$GOVERSION # GOROOT 设置
export GOPATH=\$GO_INSTALL_DIR/gopath     # GOPATH 设置
#export GOPROXY=https://goproxy.cn,direct # GOPROXY 设置
export GO111MODULE="on" # 开启 Go moudles 特性
export GOSUMDB=off # 关闭校验 Go 依赖包的哈希值
export PATH=\$GOROOT/bin:\$GOPATH/bin:\$PATH
EOF

source ~/.zshrc

配置静态IP地址

如果是WSL,可忽略此配置

# This is the network config written by 'subiquity'
network:
  renderer: networkd
  ethernets:
    ens33:
      addresses:
        - 192.168.141.101/24
      nameservers:
        addresses: [192.168.141.2]
      routes:
        - to: default
          via: 192.168.141.2
  version: 2