linux - 如何授予普通用户 shell 访问特定文件夹的权限

标签 linux permissions debian cron

我需要授予另一个开发人员 SSH 读/写访问 Web 根目录和 Debian 机器上的 crontab 的权限。通常我是唯一登录的人,所以我使用 root 用户来登录。这个新用户不完全受信任,所以我不能给他 root 访问权限。

到目前为止,我已经设法将他创建为用户:

useradd -m --shell=/bin/bash newUser

我已经安装了他的公钥,这样他就可以通过 SSH 登录。

现在我需要授予他对运行在该服务器上的几个站点之一的 Web 根目录的读/写访问权限。他还需要能够编辑 crontab。

我需要做什么?

更新:

我实际上想出了(我认为)该怎么做。

  1. 修改了新用户组:

    usermod -g mySiteGroup newUser

  2. 递归地向网络根文件夹添加读/写权限

    chmod -R g+rw/var/www/mySite

这似乎有效。如果我遗漏了任何重要信息或遗留了任何未妥善保管的元素,请告诉我。谢谢 提前致谢

最佳答案

虽然设置不是很糟糕,但我会这样做:

  • 创建一个组“dev”/“developers”
  • 将您自己和新用户添加到其中(请注意,这样做我强烈反对经常使用 root 帐户)
  • chown 网络服务器根目录以使其归“开发人员”组所有
  • 然后递归地 chmod 到 775/770(这是你唯一的选择,作为服务器管理员,随意摆弄它)

这应该做得很好,现在对于 crontab,这里是它的手册页的摘录:

If the /etc/cron.allow file exists, then you must be listed (one user per line) therein in order to be allowed to use this command. If the /etc/cron.allow file does not exist but the /etc/cron.deny file does exist, then you must not be listed in the /etc/cron.deny file in order to use this command.

If the -u option is given, it specifies the name of the user whose crontab is to be used (when listing) or modified (when editing). If this option is not given, crontab examines "your" crontab, i.e., the crontab of the person executing the command. Note that su(8) can confuse crontab and that if you are running inside of su(8) you should always use the -u option for safety's sake.

浏览 crontab 的文档,然后返回此处分享结果和进一步的问题。

关于linux - 如何授予普通用户 shell 访问特定文件夹的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9974244/

相关文章:

mysql - 在没有任何第三方库的情况下从 MySQL 触发 shell 脚本

linux - SSH 后的初始欢迎消息(横幅)不允许命令正确执行

sql-server - 有没有办法同时更改 SQL-server 数据库中所有表的权限?

php - PHP 脚本/目录有哪些权限?

linux - 安装 Git 时出现 Debian Squeeze apt-get 错误?

shell - 每半小时的 cron 作业

c++ - Vortex86DX C++ 代码/工具链构建上的非法指令

SSIS 包在 SQL 作业中作为步骤调用时未运行

php - 使用官方 php docker 镜像并在启动时运行 memcached

arrays - 如何在for循环中用值填充数组