Skip to content

Instantly share code, notes, and snippets.

@monsterxcn
Last active January 8, 2023 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monsterxcn/8c12cebdaea96fd7f675ee599153c2d3 to your computer and use it in GitHub Desktop.
Save monsterxcn/8c12cebdaea96fd7f675ee599153c2d3 to your computer and use it in GitHub Desktop.
Ubuntu 服务器初始化
# For pip installed by get-pip.py
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

Ubuntu 22.04

# 添加用户 msx
sudo useradd -r -m -s /bin/bash msx
passwd msx
sudo chmod +w /etc/sudoers
sudo nano /etc/sudoers
sudo chmod -w /etc/sudoers

# 安装 pip
python3 -V
curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm get-pip.py
# 添加 PATH
echo $SHELL
nano ~/.bash_profile
source ~/.bash_profile
# 安装 poetry
pip -V
pip install launchpadlib poetry
# * 安装 PDM
# sudo apt install python3.10-venv
# curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
# pdm completion bash > pdm.bash-completion
# sudo mv pdm.bash-completion /etc/bash_completion.d/pdm.bash-completion

# 安装 Docker Engine
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Local Windows

# 使用 SSH Key 登录
$USER_AT_HOST="username@IP"
$PUBKEYPATH="$HOME\.ssh\id_rsa-remote-ssh.pub"
$pubKey=(Get-Content "$PUBKEYPATH" | Out-String); ssh "$USER_AT_HOST" "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo '${pubKey}' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
# User privilege specification
root ALL=(ALL:ALL) ALL
msx ALL=(ALL:ALL) ALL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment