在VMWare中安装Debian12.5虚拟机后, 需要开始进行一些设置:

 

1. 先设置网络模式为桥接模式, 这样和主机在同一个局域网,方便后续ssh连接

2. 第1步设置后,重启Debian,登录后, 查看IP和Mac地址, 192.168.31.16,00:0c:29:6c:31:e6

3. 设置路由器,固定IP: 192.168.31.105。  方便后续通过域名 免密登录.  这样做为了防止每次重启重新分配IP。  设置完后重启

4. 开始免密登录设置:

ssh-keygen -t rsa
ssh-copy-id dzq@192.168.31.105

debian 系统服务器搭建_IP

 

5. 测试免密登录

debian 系统服务器搭建_重启_02

6. 设置主机hoots

debian 系统服务器搭建_桥接模式_03

 7.  测试通过主机名,连接

debian 系统服务器搭建_重启_04

 8.  设置ssh配置, 禁止密码登录, 禁止root登录

PasswordAuthentication no

PubkeyAuthentication yes

PermitRootLogin no

然后重启

9.  设置阿里源

切到root,然后执行命令:

cat <<EOF | tee /etc/apt/sources.list
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
EOF

10.  更新源 并安装sudo

debian 系统服务器搭建_重启_05

 11. 将dzq加入sudo

执行: visudo

debian 系统服务器搭建_桥接模式_06

 保存退出

 

至此整个环境算是完成了!

主要做了几个事情:

1. 固定服务器ip, 并添加本地域名映射

2. 设置免密登录

3. 设置ssh, 只能允许密钥登录,禁止root登录

4. 更新apt源为阿里云的debian源

5. 安装sudo, 并添加当前用户dzq