Virmach配置Debian ACME,Nginx...
1、进入后台,选择对应的服务2、选择 Control Panel
3、选择 Manage
4、选择 Reinstall
5、选择 Debian 9 64bit Minimal
6、记住密码
7、然后通过SSH连接VPS
Linux QuietEvergreen-VM 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
8、使用 passwd 命令修改密码,输入两遍密码
root@QuietEvergreen-VM:~# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
9、安装 Screen
apt install screen
The following NEW packages will be installed:
screen
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
10、启动 Screen
screen -S s
11、生成 RSA 密钥对
root@QuietEvergreen-VM:~# ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:NeqEoukPQ2qi6UBq5XITvzkt3P5iKDLlnsOncgCONWg root@QuietEvergreen-VM
The key's randomart image is:
+-------+
| |
| |
| . o |
|oEo . o . |
|=o.+. . S |
|+=o+o. o |
|=+X+..+ . |
|**oOo*o= |
|+.B=*o=.o. |
+---------+
11、新建文件夹 Z:\.ssh 【输入 .ssh. 】
12、通过 SFTP 连接VPS,下载密钥对
sftp> get ~/.ssh/*
Downloading authorized_keys from /root/.ssh/authorized_keys
100% 748 bytes 748 bytes/s 00:00:01
/root/.ssh/authorized_keys: 748 bytes transferred in 1 seconds (748 bytes/s)
Downloading id_rsa from /root/.ssh/id_rsa
100% 3KB 3KB/s 00:00:01
/root/.ssh/id_rsa: 3243 bytes transferred in 1 seconds (3243 bytes/s)
Downloading id_rsa.pub from /root/.ssh/id_rsa.pub
100% 748 bytes 748 bytes/s 00:00:01
/root/.ssh/id_rsa.pub: 748 bytes transferred in 1 seconds (748 bytes/s)
13、删除密钥对
root@QuietEvergreen-VM:~# rm ~/.ssh/id_rsa*
14、使用 PuTTY Key Generator 转换私钥添加口令
File——Load priate key
Save private key——选择.ssh——保存为id_rsa.ppk
15、修改 sshd_config 文件并检查
root@QuietEvergreen-VM:~# cat << EOF > /etc/ssh/sshd_config
> AcceptEnv LANG LC_*
> ChallengeResponseAuthentication no
> PasswordAuthentication no
> PermitRootLogin yes
> Port 22
> PrintMotd no
> PubkeyAuthentication yes
> Subsystem sftp /usr/lib/openssh/sftp-server
> UsePAM yes
> X11Forwarding yes
> EOF
root@QuietEvergreen-VM:~# sshd -t
16、重新启动 SSH 服务
systemctl restart sshd
17、使用SSH密钥登录连接 VPS
Linux QuietEvergreen-VM 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@QuietEvergreen-VM:~#
18、升级系统
screen -S s
apt update && \
apt upgrade && \
apt full-upgrade && \
apt autoremove && \
apt autoclean
19、升级到 Debian 10
sed -i 's/stretch/buster/g' /etc/apt/sources.list && \
apt update && \
apt upgrade && \
apt full-upgrade && \
apt autoremove && \
apt autoclean
20、使用新内核启动
systemctl reboot
21、移除旧内核
root@QuietEvergreen-VM:~# screen -S s
root@QuietEvergreen-VM:~# dpkg --get-selections | grep linux
console-setup-linux install
firmware-linux-free install
libselinux1:amd64 install
linux-base install
linux-image-4.19.0-6-amd64 install
linux-image-4.9.0-11-amd64 install
linux-image-4.9.0-4-amd64 install
linux-image-amd64 install
util-linux install
util-linux-locales install
root@QuietEvergreen-VM:~# apt autoremove --purge linux-image-4.9.0-4-amd64 linux-image-4.9.0-11-amd64
Reading package lists... Done
root@QuietEvergreen-VM:~# dpkg --get-selections | grep linux
console-setup-linux install
firmware-linux-free install
libselinux1:amd64 install
linux-base install
linux-image-4.19.0-6-amd64 install
linux-image-amd64 install
util-linux install
util-linux-locales install
22、更新 grub
root@QuietEvergreen-VM:~# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.19.0-6-amd64
Found initrd image: /boot/initrd.img-4.19.0-6-amd64
done
23、开启 BBR
root@QuietEvergreen-VM:~# echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf && \
> echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf && \
> sysctl -p && \
> lsmod |grep bbr
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
tcp_bbr 204801
root@QuietEvergreen-VM:~#
24、安装 acme.sh
root@QuietEvergreen-VM:~# apt install curl
root@QuietEvergreen-VM:~# curl https://get.acme.sh | sh
Install success!
root@QuietEvergreen-VM:~# echo 'alias acme.sh=~/.acme.sh/acme.sh' >> /etc/profile
root@QuietEvergreen-VM:~# source /etc/profile
root@QuietEvergreen-VM:~# acme.sh --upgrade --auto-upgrade
Install success!
Upgrade success!
root@QuietEvergreen-VM:~#
25、签发证书 【使用 cloudflare】
export CF_Email=cloudflare@gmail.com
export CF_Key=d2d833bd132a12a5de698b64ec5e4c91d8da6
acme.sh --issue -d domain.com -d *.domain.com --dns dns_cf
26、安装证书
mkdir -p /etc/nginx/ssl/domain.com && \
~/.acme.sh/acme.sh --install-cert -d domain.com \
--cert-file /etc/nginx/ssl/domain.com/domain.com.cer \
--ca-file /etc/nginx/ssl/domain.com/ca.cer \
--key-file /etc/nginx/ssl/domain.com/domain.com.key \
--fullchain-file /etc/nginx/ssl/domain.com/fullchain.cer \
--reloadcmd "service nginx force-reload"
Installing cert to:/etc/nginx/ssl/domain.com/domain.com.cer
Installing CA to:/etc/nginx/ssl/domain.com/ca.cer
Installing key to:/etc/nginx/ssl/domain.com/domain.com.key
Installing full chain to:/etc/nginx/ssl/domain.com/fullchain.cer
Run reload cmd: service nginx force-reload
Failed to restart nginx.service: Unit nginx.service not found.
Reload error for :
27、安装V*R*y
root@QuietEvergreen-VM:~# bash <(curl -L -s https://install.direct/go.sh)
PORT:10101
UUID:ec7e2136-8ab8-43dc-86b8-10861c5cafc2
Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service.
V2Ray v4.21.3 is installed.
root@QuietEvergreen-VM:~# systemctl start v2ray
root@QuietEvergreen-VM:~# cat /etc/v2ray/config.json
{
"inbounds": [{
"port": 23222,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "ec7e2136-8ab8-43dc-86b8-10861c5cafc2",
"level": 1,
"alterId": 64
}
]
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
},{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}],
"routing": {
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "blocked"
}
]
}
}
28、安装 Nginx
root@QuietEvergreen-VM:~# apt install nginx
The following NEW packages will be installed:
nginx nginx-common nginx-full
0 upgraded, 23 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,559 kB of archives.
After this operation, 10.1 MB of additional disk space will be used.
Do you want to continue?
页:
[1]