Featured image of post PVE配置SSH服务

PVE配置SSH服务

PVE 配置 SSH 服务

1、 安装SSH服务器软件包

更新软件索引+安装SSH+SSH开机自启

1
sudo apt-get update && sudo apt-get install openssh-server && sudo systemctl start ssh && sudo systemctl enable ssh

2、查看SSH配置文件

1
cat /etc/ssh/sshd_config

3、修改配置文件+重启ssh服务,使配置生效+查看IP地址

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sudo sed -i.bak \
  -e '/Port 22/ a Port 22' \
  -e '/PermitRootLogin/ a PermitRootLogin yes' \
  -e '/GSSAPIAuthentication/ a GSSAPIAuthentication no' \
  -e '/UseDNS/ a UseDNS no' \
  -e '/ClientAliveInterval/ a ClientAliveInterval 10' \
  -e '/ClientAliveCountMax/ a ClientAliveCountMax 999' \
  /etc/ssh/sshd_config

systemctl restart ssh && hostname -i

解释如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
-i.bak备份为sshd_config.bak
#Port 22
#PermitRootLogin prohibit-password
#GSSAPIAuthentication no
#UseDNS no
SSH保持连接
#ClientAliveInterval 0
#ClientAliveCountMax 3
>> 修改为:
Port 22
PermitRootLogin yes
GSSAPIAuthentication no
UseDNS no
SSH保持连接
ClientAliveInterval 10
ClientAliveCountMax 999
最后更新于 2025-02-22
本博客已稳定运行 小时 分钟
共发表 112 篇文章 · 总计 109.83 k 字
本站总访问量