国内服务器
本文最后更新于 113 天前,如有失效请评论区留言。

SSH 通过密钥登录

通过MobaXterm生成ssh密钥

image-20230301013117180

先保存生成的私钥到本地

image-20230301013536888

cd .ssh
vim authorized_keys

粘贴生成的公钥

image-20230301013501628

chmod 600 authorized_keys
chmod 700 ~/.ssh

设置ssh

vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin without-password
PasswordAuthentication no
service sshd restart

如果是国内的腾讯云轻量服务器

备份镜像

mv /etc/apt/sources.list /etc/apt/sources.list.bak

更改源镜像

vim /etc/apt/sources.list

腾讯云内网镜像

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.tencentyun.com/ubuntu jammy main restricted
# deb-src http://mirrors.tencentyun.com/ubuntu jammy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.tencentyun.com/ubuntu jammy-updates main restricted
# deb-src http://mirrors.tencentyun.com/ubuntu jammy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.tencentyun.com/ubuntu jammy universe
# deb-src http://mirrors.tencentyun.com/ubuntu jammy universe
deb http://mirrors.tencentyun.com/ubuntu jammy-updates universe
# deb-src http://mirrors.tencentyun.com/ubuntu jammy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.tencentyun.com/ubuntu jammy multiverse
# deb-src http://mirrors.tencentyun.com/ubuntu jammy multiverse
deb http://mirrors.tencentyun.com/ubuntu jammy-updates multiverse
# deb-src http://mirrors.tencentyun.com/ubuntu jammy-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
#deb http://mirrors.tencentyun.com/ubuntu jammy-backports main restricted universe multiverse
# deb-src http://mirrors.tencentyun.com/ubuntu jammy-backports main restricted universe multiverse

deb http://mirrors.tencentyun.com/ubuntu jammy-security main restricted
# deb-src http://mirrors.tencentyun.com/ubuntu jammy-security main restricted
deb http://mirrors.tencentyun.com/ubuntu jammy-security universe
# deb-src http://mirrors.tencentyun.com/ubuntu jammy-security universe
deb http://mirrors.tencentyun.com/ubuntu jammy-security multiverse
# deb-src http://mirrors.tencentyun.com/ubuntu jammy-security multiverse

自动获取最佳镜像地址

一行命令查询(较准确)

curl -s http://mirrors.ubuntu.com/mirrors.txt | xargs -I {} sh -c 'echo $(curl -r 0-102400 -s -w %{speed_download} -o /dev/null {}/ls-lR.gz) {}' | sort -g -r | head -1 | awk '{ print $2  }'

创建脚本

touch ~/mirror.sh && cd ~ && nano mirror.sh

通过mirrors.ubuntu.com根据geo返回当前地区的镜像列表,然后根据下载速度找到最优的地址并修改

#!/bin/bash
function ci_pick_ubuntu_mirror() {
  echo "根据下载速度选择最快最新的Ubuntu镜像..."
  UBUNTU_MIRROR=$({
    # choose mirrors that are up-to-date by checking the Last-Modified header for
    {
      curl -s http://mirrors.ubuntu.com/mirrors.txt
      echo https://mirrors.ustc.edu.cn/ubuntu/
    } | xargs -I {} sh -c 'echo "$(curl -m 5 -sI {}dists/$(lsb_release -c | cut -f2)-security/Contents-$(dpkg --print-architecture).gz|sed s/\\r\$//|grep Last-Modified|awk -F": " "{ print \$2 }" | LANG=C date -f- -u +%s)" "{}"' | sort -rg | awk '{ if (NR==1) TS=$1; if ($1 == TS) print $2 }'
  } | xargs -I {} sh -c 'echo `curl -r 0-102400 -m 5 -s -w %{speed_download} -o /dev/null {}ls-lR.gz` {}' \
    |sort -g -r |head -1| awk '{ print $2  }')
  if [ -z "$UBUNTU_MIRROR" ]; then
      # fallback to full mirrors list
      UBUNTU_MIRROR="mirror://mirrors.ubuntu.com/mirrors.txt"
  fi
  OLD_MIRROR=$(cat /etc/apt/sources.list | grep '^deb ' | head -1 | awk '{ print $2 }')
  echo "Picked '$UBUNTU_MIRROR'. Current mirror is '$OLD_MIRROR'."
  if [[ "$OLD_MIRROR" != "$UBUNTU_MIRROR" ]]; then
    sudo sed -i "s|$OLD_MIRROR|$UBUNTU_MIRROR|g" /etc/apt/sources.list
    sudo apt-get update
  fi
  # set the chosen mirror also in the UBUNTU_MIRROR and UBUNTU_SECURITY_MIRROR environment variables
  # that can be used by docker builds
  export UBUNTU_MIRROR
  export UBUNTU_SECURITY_MIRROR=$UBUNTU_MIRROR
  # make environment variables available for later GitHub Actions steps
  if [ -n "$GITHUB_ENV" ]; then
    echo "UBUNTU_MIRROR=$UBUNTU_MIRROR" >> $GITHUB_ENV
    echo "UBUNTU_SECURITY_MIRROR=$UBUNTU_SECURITY_MIRROR" >> $GITHUB_ENV
  fi
}
ci_pick_ubuntu_mirror

粘贴进去然后Ctrl+O 然后回车保存,Ctrl+x退出

然后执行脚本

bash mirror.sh

查看下是否更改

cat /etc/apt/sources.list
deb http://mirrors.huaweicloud.com/repository/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.huaweicloud.com/repository/ubuntu/ jammy main restricted universe multiverse

deb http://mirrors.huaweicloud.com/repository/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.huaweicloud.com/repository/ubuntu/ jammy-security main restricted universe multiverse

deb http://mirrors.huaweicloud.com/repository/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.huaweicloud.com/repository/ubuntu/ jammy-updates main restricted universe multiverse

deb http://mirrors.huaweicloud.com/repository/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.huaweicloud.com/repository/ubuntu/ jammy-backports main restricted universe multiverse

添加git镜像

git config --global url."https://gitclone.com/".insteadOf https://

更新

apt update
apt upgrade

安装常用软件

apt install -y ncdu htop zsh ranger neofetch git

github域名国内加速

vim /etc/hosts

使用https://github.com/ovenx/github-hosts更新内容

如果使用vim从第三行删除到最后可以使用快捷键

3G
dG

如果上面的还是不行,添加代理

export http_proxy=http://192.168.1.2:7890/
export https_proxy=http://192.168.1.2:7890/

设置全局代理

sudo nano /etc/environment
http_proxy="http://192.168.1.2:7890/"
https_proxy="http://192.168.1.2:7890/"
ftp_proxy="http://192.168.1.2:7890/"
no_proxy="localhost,127.0.0.1,::1"

添加完成后保存重启

sudo reboot

oh-my-zsh

apt install -y zsh

下载并执行脚本

sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

如果想所有用户都可以使用添加环境变量

ZSH=/ohmyzsh sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

或者使用jsdelivr的cdn

ZSH=/ohmyzsh sh -c "$(wget -O- https://cdn.jsdelivr.net/gh/ohmyzsh/ohmyzsh/tools/install.sh)"

git clone 加速

如果jsdelivr被墙或者不稳定就找个Github文件加速 如:https://gh.api.99988866.xyz/

ZSH=/ohmyzsh sh -c "$(wget -O- https://gh.api.99988866.xyz/https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone https://gitclone.com/github.com/ohmyzsh/ohmyzsh
git clone https://gitcode.net/mirrors/ohmyzsh/ohmyzsh.git
git clone https://gitee.com/TheWish/zsh-autosuggestions.git
git clone https://kgithub.com/ohmyzsh/ohmyzsh.git
git clone https://ghproxy.com/https://github.com/ohmyzsh/ohmyzsh

安装 zsh 命令提示

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
nano ~/.zshrc

在plugins里面添加

zsh-autosuggestions

如果前面默认有其他插件需要中间添加一个空格

image-20230301104121108

刷新当前环境

source ~/.zshrc

有代理的国外docker安装

更新apt包索引并安装包以允许apt通过 HTTPS 使用存储库

sudo apt update
sudo apt install ca-certificates curl gnupg

添加Docker官方GPG密钥

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo 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://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

更新apt包索引

sudo apt update

安装 Docker 引擎、containerd 和 Docker Compose

sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

通过运行hello-world镜像来验证Docker Engine安装是否成功

sudo docker run hello-world

国内docker安装 https://get.daocloud.io/

curl -sSL https://get.daocloud.io/docker | sh

安装 Docker Compose

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.17.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

根据各自平台修改Docker镜像源

https://cloud.tencent.com/document/product/1207/45596

vim /etc/docker/daemon.json
{
   "registry-mirrors": [
       "https://mirror.ccs.tencentyun.com"
  ]
}
sudo systemctl restart docker

华为云镜像docker加速 https://juejin.cn/post/6991761398002876424

版权声明:本文为BIMiracle原创,依据CC BY-SA 4.0许可证进行授权,转载请附上出处链接及本声明。
暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇