CentOS SFTP配置更新主要涉及更新OpenSSH软件包及修改配置文件,步骤如下:
备份配置文件
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
更新系统及OpenSSH
sudo yum update openssh-server
sudo dnf update openssh-server
修改SFTP配置(可选)
编辑/etc/ssh/sshd_config,调整以下参数(如需限制用户或路径):
sudo nano /etc/ssh/sshd_config
# 确保以下行未被注释,路径需与系统实际一致
Subsystem sftp /usr/libexec/openssh/sftp-server
# 示例:限制用户到指定目录
Match Group sftpusers
ChrootDirectory %h
ForceCommand internal-sftp
重启SSH服务
sudo systemctl restart sshd
验证更新
ssh -V # 客户端版本
sftp -V # 服务端版本
sudo systemctl status sshd
注意:更新前确保配置文件语法正确,可通过sshd -T测试配置。若需自定义SFTP路径,需确认sshd -T | grep sftp获取实际路径。