linux中系统用户禁用shell访问,只允许ftp访问的配置

默认情况下,在创建用户时,如果未明确指定,该用户将具有对服务器的 SSH 访问权限。

要禁用 shell 访问,我们将创建一个新的 shell,它会简单地打印一条消息,告诉用户他们的帐户仅限于 FTP 访问。

 

1 运行以下命令以创建 /bin/ftponly shell 并使其可执行

echo -e '#!/bin/sh\necho "This account is limited to FTP access only."' | sudo tee -a  /bin/ftponly
sudo chmod a+x /bin/ftponly

2 将新 shell 附加到 /etc/shells 文件中的有效 shell 列表中

echo "/bin/ftponly" | sudo tee -a /etc/shells

3 将用户 shell 更改为 /bin/ftponly

sudo usermod newftpuser -s /bin/ftponly
posted @ 2021-07-22 18:43  我要去巴萨  阅读(502)  评论(0编辑  收藏  举报