云服务器配置教程

用户创建、免密登录即基本软件安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ssh root@公网ip
adduser lmj
usermod -aG sudo lmj
apt update
apt install sudo
<ctrl + d>退出云服务器

vim ~/.ssh/config

***

Host lmj
HostName 公网ip
User lmj

***

ssh-copy-id lmj或者将公钥文件id_rsa.pub内容复制到服务器~/.ssh/authorized_keys文件中。
scp .bashrc .vimrc .tmux.conf lmj:

ssh lmj
sudo apt update
sudo apt install tmux

docker安装

参考官方安装文档

1
2
3
4
5
6
7
8
9
10
11
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
docker --version

docker镜像配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# docker镜像下载

scp /var/lib/acwing/docker/images/docker_lesson_1_0.tar lmj:
ssh lmj
docker load -i docker_lesson_1_0.tar
docker run -p 20000:22 --name my_docker_server -itd docker_lesson:1.0
docker attach my_docker_server
passwd
去阿里云开放20000端口
ssh root@xxx.xxx.xxx.xxx -p 20000

# 配置docker容器

```bash
ssh root@公网ip
adduser acs
usermod -aG sudo acs
apt update
apt install sudo
<ctrl + d>退出云服务器

vim ~/.ssh/config

***

Host lmjd
HostName 公网ip
User acs
Port 20000

***

ssh-copy-id lmjd
scp .bashrc .vimrc .tmux.conf lmjd:

ssh lmjd
sudo apt update
sudo apt install tmux
```