我有一个通过 FreeBSD 上的实用程序创建的用户pw
。我使用的完整命令是:
pw add user example -s /usr/local/scripts/example.sh -w none
Run Code Online (Sandbox Code Playgroud)
用户可以作为示例登录,无需密码,这将运行示例脚本。脚本运行完成后,用户将自动注销。
我想复制该用户,但我正在寻找一种无需实用程序即可完成此操作的方法。例如,我考虑修改该/etc/passwd
文件,但看起来不起作用。我说它不起作用的原因是因为它提示我输入密码,当然我没有为我尝试添加的该用户设置密码。
我所追求的可能吗?我绝对必须使用诸如 之类的实用程序吗pw
?
只需快速编辑即可。也许我唯一缺少的就是将用户设置为不需要密码。我的编辑/etc/passwd
可能是正确的,我所需要的只是以某种方式将这个新用户设置为不需要密码。
我创建了 user small
,将他添加到组kek
并允许该组仅读取用户主目录中的文件。然后我将所有文件 chown 到root:kek
. 但是,small
仍然可以删除他家目录中的文件。
我运行的命令:
useradd -ms /bin/bash small
groupadd kek
usermod -a -G kek small
chown -R root:kek /home/small/*
chmod -R g=r /home/small/*
Run Code Online (Sandbox Code Playgroud)
然后当我尝试删除文件时:
$ ls -l
total 16
-rw-r--r-- 1 root kek 240 Jun 23 06:17 Dockerfile
-rw-r--r-- 1 root kek 39 Jun 21 09:17 flag.txt
-rw-r--r-- 1 root kek 2336 Jun 22 14:19 server.py
-rw-r--r-- 1 root kek 24 Jun 22 08:16 small.py
$ rm flag.txt
$ ls …
Run Code Online (Sandbox Code Playgroud) 为了做一个限制访问的文件服务器,我设置了以下配置:
在文件服务器上 (Debian Wheezy)
data-reader
不在家,无壳,命名为组中data
。/somewhere/share/
由 root 拥有的目录,其子目录/somewhere/share/data/
可由 group 访问data
。/etc/sshd_config
:
Match group data
ChrootDirectory /somewhere/share
ForcedCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
Run Code Online (Sandbox Code Playgroud)这样,data-reader
只能使用 SFTP 读取目录中的文件/somewhere/share/data
。好的。
在客户端(另一个 Debian)
使用sftp data-reader@<server_ip>
连接到服务器。从 SFTP 控制台,我可以使用/somewhere/share/data
SFTP 命令(如ls
或 )以只读方式访问get
,但我看不到其他路径。好的 !这就是我想要的。
但是有一个很好的命令列出help
:
! Escape to local shell
Run Code Online (Sandbox Code Playgroud)
如果我跑
!ls /
Run Code Online (Sandbox Code Playgroud)
我实际上可以看到/
服务器上的所有文件!我可以看到任何文件的内容。但我不希望那样,我希望用户不能离开他的目录。
有没有办法限制这个“转义”命令的访问?
感谢您的帮助。
我们想在所有用户的家中创建一个个人 bin 目录。
有没有什么办法可以在我们第一次创建用户时,默认创建一个 ~/bin 文件夹?
我创建了一个新用户,adduser
但是当我尝试从他的帐户 sudo 时,我得到了xxxx * is not in the sudoers file. This incident will be reported.
.
所以我开始篡改visudo
命令......
我知道 root 帐户具有以下配置:
root ALL=(ALL:ALL) ALL
Run Code Online (Sandbox Code Playgroud)
但我不想为我的新用户复制这个...
我希望我的用户 xxxx 没有 root 访问权限,除非使用 sudo。
使用 sudo 时,我希望 xxxx 用户提示输入 root 密码而不是他自己的密码!!
谢谢
使用 debian 10
VM,仅 ssh
我在 CentOS 8.2 上,我无法使用useradd
命令添加用户
[root@localhost ~]# useradd -m /home/alice -c "ALICE ADMIN" -s /usr/bin/bash alice
Usage: useradd [options] LOGIN
useradd -D
useradd -D [options]
Options:
-b, --base-dir BASE_DIR base directory for the home directory of the
new account
-c, --comment COMMENT GECOS field of the new account
-d, --home-dir HOME_DIR home directory of the new account
-D, --defaults print or change default useradd configuration
-e, --expiredate EXPIRE_DATE expiration date of the new account
-f, --inactive INACTIVE password inactivity …
Run Code Online (Sandbox Code Playgroud) 我的 PC 上安装了 Ubuntu 12.04,最近我进行了编辑/etc/passwd
和更改
user1:x:00:00:user1,,,:/home/user1:/bin/bash
Run Code Online (Sandbox Code Playgroud)
给 user1 授予 root 权限,系统总是需要以 root 身份登录,以运行一些自定义软件。
现在似乎声音不起作用,音量图标被禁用。我知道pulseaudio
恶魔不能以 root 身份运行,这就是音频不起作用的原因。我该如何解决,比如设置pulseaudio的权限以root身份运行。
当我输入命令时
/usr/bin/pulseaudio --start
Run Code Online (Sandbox Code Playgroud)
给我输出
W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
E: [autospawn] core-util.c: Home directory /home/user1 not ours.
W: [autospawn] lock-autospawn.c: Cannot access autospawn lock.
E: [pulseaudio] main.c: Failed to acquire autospawn lock
Run Code Online (Sandbox Code Playgroud)
编辑
问题的解决方法:
我通过禁用对pulseaudio均衡器的根检查来解决这个问题
sed -i 's/exit 1/#exit1/g' /usr/bin/pulseaudio-equalizer
Run Code Online (Sandbox Code Playgroud) I have Linux a server where I would like to add few other people besides me as a root users. All the users need to access this server very seldom if ever. As a first step I set a root
user a password which we all know. Then I added those users with useradd
:
useradd -ou 0 -g 0 user1 -d /root/user1/ -s /bin/bash
useradd -ou 0 -g 0 user2 -d /root/user2/ -s /bin/bash
Run Code Online (Sandbox Code Playgroud)
After that I copied a …
在/etc/sudoers
我补充说:
%myuser ALL=(ALL) NOPASSWD:ALL
现在,如果我输入,sudo apt update
我不需要输入密码。
但我想要完整的 root 权限:即,我只想使用apt update
.
apt 是我想要 FULL ROOT PERMISSIONS 的一个例子,另一个例子是能够在任何地方创建/修改文件。
我试图root ALL=(ALL:ALL) ALL
在 myuser 行中使用根行 ( ) 但什么也没用:
%myuser ALL=(ALL:ALL) ALL
这是我的/etc/sudoers
文件:
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write …
Run Code Online (Sandbox Code Playgroud) 当我以 登录时username
,为什么
sudo ls ~
Run Code Online (Sandbox Code Playgroud)
向我展示而不是的内容?我认为以 root 身份执行命令,在这种情况下将代表./home/username
/root
sudo
~
/root
更多解释:
此外,如果我运行su
命令,然后运行ls ~
,我会看到/root
. 所以我认为这样做相当于sudo ls ~
.
再举一个例子,一些带有--user
标志的命令在以sudo
. 例如,将安装到 内的目录 ,而 将安装到. 请注意,不建议运行最后一个命令,我只是使用它来显示我所描述的功能。pip install --user packagename
/home/username
sudo pip install --user packagename
/root
有没有办法对 Unix PAM 子系统上 SSH 服务器上的所有用户强制执行双因素身份验证 (2FA)?