centos

如何自定义CentOS SFTP提示信息

小樊
49
2025-07-16 18:51:20
栏目: 智能运维

要自定义 CentOS 上的 SFTP 提示信息,您需要修改 OpenSSH 服务器的配置文件

  1. 使用文本编辑器打开 /etc/ssh/sshd_config 文件。例如,使用 nano 编辑器:
sudo nano /etc/ssh/sshd_config
  1. 在文件中找到或添加以下行:
Banner /etc/ssh/banner.sftp

这告诉 SSH 服务器在用户登录时显示 /etc/ssh/banner.sftp 文件中的内容。

  1. 创建或编辑 /etc/ssh/banner.sftp 文件:
sudo nano /etc/ssh/banner.sftp
  1. banner.sftp 文件中输入您想要显示的自定义提示信息。例如:
Welcome to the SFTP server!
Please read the following rules carefully:
1. Do not share your account with others.
2. Do not attempt to access files or directories that you do not have permission to access.
3. Violation of these rules may result in termination of your account.
  1. 保存并关闭文件。

  2. 重新启动 SSH 服务以使更改生效:

sudo systemctl restart sshd

现在,当用户通过 SFTP 登录时,他们将看到您自定义的提示信息。请注意,这些更改仅适用于使用 SFTP 的用户,而不是通过 SSH 访问系统的用户。

0
看了该问题的人还看了