我有个用户,他是个无名小卒。我需要和他一起执行shell脚本文件,并让他作为sudo执行一个块。例如:
su root <<"AS_ROOT"
# do something with my linux
AS_ROOT
但什么都不管用。我试过:su - root <<... sudo -s -- <<...
它对我咆哮。我在ubuntu 16.04 lts上。
谢谢。
我所要做的事情的整个目标是成为根用户并运行一个进程。但是,我创建了一个进程,调用一个辅助主机,并运行一个脚本来获取我想要的Linux主机的根密码。在此之后,我将密码传回var ansible_become_password:。尽管每次我传递它时,它都会抛出"password is undefined“错误。
我查找变量优先级,但当我尝试另一种方式时,我收到了相同的错误。
代码:
# Root
- name: Run as root user. privileged escalation using su
hosts: 10.x.x.1
gather_facts: false
在这里,我创建了一个linux脚本来执行一个程序来回显“用户作为root登录”。但它不会显示任何东西。如果我给出‘退出’,那么它将显示“用户登录为root”。请帮我解决这个问题。
#!/bin/bash
logged_user=`whoami`
if [ $logged_user != root ]
then echo "You are not logged as root!"
echo "Enter root password if root password is set"
su
我有一个Ubuntu 14.04服务器,我不能使用任何依赖于su的东西。这表现为无法重新启动服务,甚至无法切换用户。
root@ci-web1:~# su - mxx
su: Authentication failure
我的/var/log/auth.log显示:
Oct 10 11:14:15 ci-web1 su[19709]: PAM unable to dlopen(pam_rootok.so): /lib/security/pam_rootok.so: cannot open shared object file: No such file or directory
Oct 10
我知道对一个文件有许可意味着什么。这意味着当其他用户对其拥有执行权限时,他们将作为文件的所有者执行。但是,当文件夹拥有suid权限时,它意味着什么呢?我做了一些测试,它似乎没有什么特别的文件夹。有人能帮上忙吗?谢谢。
我正在使用Oracle Linux 7.6。
root:[~]# cat /etc/*release*
Oracle Linux Server release 7.6
NAME="Oracle Linux Server"
VERSION="7.6"
ID="ol"
VARIANT="Server"
VARIANT_I
首先,我对Linux很陌生。我用-M选项创建了一个名为"ginny“的新用户。
现在,我试图用usermod -d /link/to/directory ginny分配一个主目录,但它没有将主目录分配给用户ginny。
% su - ginny returns an error
su: warning : cannot chance directory to /abc: No such file or directory
-bash-3.2$:
pwd命令为用户ginny返回/root (可能是因为我还没有为她创建主目录),但是现在是否有任何开关可以允许我将主目录分配给用户ginny
所以这是一个奇怪的问题。我正在使用Linux AMI [root@test /]# cat /etc/*release
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:lin
[root@mymachine redisc]# docker run -p 6379:6379 --user myuser redisc
docker: Error response from daemon: linux spec user: unable to find user myuser: no matching entries in passwd file.
但是我可以成为我在主机上的用户
[root@mymachine redisc]# sudo su myuser
[myuser@mymachine redisc]#
我如何才能在容器中以myuser身份运行?