一、开启sudo命令

1.使用apt下载sudo(实际上debian自带sudo,此操作为安装sudo)

sudo apt install sudo

size:800,1000

2.配置特权用户

放在%sudo ALL=(ALL:ALL) ALL下方 username(用户名) ALL=(ALL:ALL) ALL

size:800,1000

3.测试权限(显示root代表权限配置成功)

sudo whoami

size:800,1000

二、配IP、网关、DNS

1.进入/etc/network文件夹

cd /etc/network

size:800,1000

2.确认网卡名称(ens18)

ip link show

size:800,1000

3.修改interfaces文件(nano编辑器)

nano interfaces

size:800,1000

nano编辑器 Ctrl + O 保存(按下后需回车确认)

nano编辑器 Ctrl + X 退出

#自启动网口ens18
auto ens18
#将网口设定为静态配置IP
iface ens18 inet static
#配置IP
address 192.168.0.2
#配置子网掩码
netmask 255.255.255.0
#配置网关
gateway 192.168.0.1
#配置DNS
dns-nameservers 114.114.114.114

4.重启网络服务

sudo systemctl restart networking

size:800,1000

5.验证网卡配置6.测试内网以及外网通讯

内网 ping 192.168.0.99

size:800,1000

外网 ping 8.8.8.8

size:800,1000

三、安装ssh,设置root登录

1.安装openssh-server

sudo apt-get install openssh-server

size:800,1000

2.启动ssh

sudo systemctl start ssh

size:800,1000

3.启用ssh

sudo systemctl enable ssh

size:800,1000

4.查看ssh状态

sudo systemctl status ssh

size:800,1000

5.进入/etc/ssh文件夹

cd /etc/ssh

size:800,1000

6.修改sshd_config文件

nano sshd_config

size:800,1000

找到 #PermitRootLogin 一行 改成 PermitRootLogin yes (取消注释) PermitRootLogin yes

size:800,1000

删掉#PasswordAuthentication yes 前面的 #

size:800,1000

7.重启ssh

sudo service ssh restart

size:800,1000

8.尝试ssh连接(Putty或MobaXterm)

Putty成功连接

MobaXterm成功连接

四、修改apt源,打补丁(使用MobaXterm方便粘贴源)

1.进入/etc/apt文件夹

cd /etc/apt

size:800,1000

2.修改sources.list文件(删除原有apt源)

nano sources.list

size:800,1000

阿里云

deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib

中科源

deb https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib

size:800,1000

3.更新源列表并升级系统

sudo apt-get update

size:800,1000

五、安装启用防火墙

1.安装防火墙

sudo apt-get install ufw

size:800,1000

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐