这个问题是关于最佳实践.我正在使用Fabric运行部署脚本.我的部署用户"部署"需要sudo重新启动服务.因此,我正在使用Fabric的Sudo函数在脚本中运行这些命令.这可以正常工作,但是在脚本执行期间提示了密码.我不想在部署期间输入密码.这里最好的做法是什么.我能想到的唯一解决方案是更改sudo权限以不需要我的部署用户运行的命令密码.这对我来说似乎不正确. 解决方案 正如Bartek所建议的那样,在Sudoers文件中为部署"用户"启用了无密码的sudo. 类似: run('echo "{0} ALL=(ALL) ALL" >> /etc/sudoers'.format(env.user)) 其他解决方案 理想的解决方案是在服务器上创建仅用于部署的用户(例如,deploy).然后,将env.user=deploy设置在您的fabfile中.然后,在服务器上,您可以在sudoers文件中逐命令授予用户的必要权限: 重要:始终使用sudo visudo修改
以下是关于 sudo 的编程技术问答
当我运行cap production deploy时,我得到cannot create directory ‘/var/www/application/repo’: Permission denied. 到目前为止,我已经创建了Deploy用户,例如: adduser deploy adduser deploy sudo 我在Capistrano中使用此用户. 的确,当我登录deploy@my.vps.ip时,默认情况下没有sudo的权限,每次我需要明确启用它,例如sudo su. . 我看到了两个可能的解决方案: 在Capistrano中启用Sudo 在Ubuntu中启用Sudo 不幸的是,我不知道该怎么做. 解决方案 默认情况下,Capistrano 3部署到/var/www,deploy用户不写.您需要使用以下命令将/var/www的所有权更改为deploy用户. sudo chown deploy:deploy /var/ww
我在詹金斯(Jenkins Warning: Identity file key.pem not accessible: Permission denied. Host key verification failed. sudo: no tty present and no askpass program specified 我找到了解决方案,说添加 jenkins ALL=(ALL) ALL /etc/sudoer中的这些行,但仍然不起作用. 解决方案 sudo su visudo -f /etc/sudoers 最后添加以下行. jenkins ALL= NOPASSWD: ALL 其他解决方案 用户名all = nopasswd:sudoers in sudoers in ubuntu Server 12.04.2
在我的Debian服务器上,我有一个名为" Deployer"的用户,该用户没有sudo访问,并且已安装了RVM. 使用" Deployer"安装Ruby(例如1.9.3)时,它会触发一个任务以安装依赖项 "Installing requirements for debian, might require sudo password." 失败并停止安装,因为" deployer"不能sudo. 我不想将" Deployer"添加到Sudoers列表中,也不想仅仅用于安装依赖项的其他用户安装RVM. 安装依赖项的正确方法是什么?或如何列出它们以手动安装? 解决方案 这确实是RVM称为autolibs的新功能,该功能自动安装依赖项. 如果您已经安装了RVM,并且它要求您提供sudo密码,则可以禁用Autolibs: $ rvm autolibs disable $ rvm requirements # manually install thes
因此,在运行导入web的脚本时,我会遇到以下错误. $ python bin/app.py Traceback (most recent call last): File "bin/app.py", line 1, in import web ImportError: No module named web 我尝试使用easy_install web,但获取此错误: $ easy_install web Searching for web Reading http://pypi.python.org/simple/web/ Reading http://www.pythonweb.org/web/ Reading http://www.pythonweb.org/web/release/ No local packages or download links found for web error: Could not find suitable dis
要从命令行执行我的python程序,我使用sudo python myProgram.py,因为我的程序需要根特权. 要从Visual Studio Code IDE执行相同的操作,我尝试将pythonPath变量在laight.json文件中使用sudo命令前缀,但我收到以下错误: 错误:Spawn sudo/usr/local/bin/python3 enoent 这是我的任务配置 { "name": "Python", "type": "python", "request": "launch", "stopOnEntry": true, "pythonPath": "sudo /usr/local/bin/python3", "program": "${file}", "cwd": "${workspaceFolder}", "env": {}, "envFile": "${worksp
WSL V.1 -VSCODE V1.40.1(使用'远程-WSL'扩展40.3) 如何使用sudo和vscode打开一个符合根的文件? (不作为根) 如果我打开一个没有sudo的root文件,我无法编辑它(预期): $ code/etc/profile.d/custom-profile.sh $ 但是,如果我尝试sudo code文件,我得到: $ sudo code /etc/profile.d/custom-profile.sh [sudo] password for xxxx: sudo: code: command not found binarify的答案下面表明我可以将默认用户切换到root,但是我绝对不想作为root运行,所以我仍在寻找另一个解决方案. 解决方案 您可以拥有要编辑的文件,然后将其归还后,然后将其归还 sudo chown myuser /path/to/file code /path/to/file sudo ch
我一直在与Google Cloud Debian VM合作,并且使用Sudo进行超级用户任务完全没有问题(Sudo并不要求密码). 今天,我像往常一样通过SSH连接,当我尝试 sudo 时,它开始询问密码: We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for -----: 根据文档,它不应像已经经过验证的连接一样询问密码. 解决方案 我自己解决了这个问题.我为有类似问题的任何人发布
我读过 pip安装在全球站点包装中安装Virtualenv 并确保一切都正确,我什至在Virtaulenv中使用Easy_install重新安装了PIP. 发生的事情很奇怪.首先,它不会让我安装一个没有sudo的软件包...如果我读取文本输出,它会像预期的那样将其放在Virtualenv路径中..然后,我使用sudo并起作用. 但是,如果我尝试安装软件包(在这种情况下为django-bootstrap3),则说明: (env)kevin@g3:~/djangoP/work$ sudo pip install django-bootstrap3 Requirement already satisfied (use --upgrade to upgrade): django-bootstrap3 in /usr/local/lib/python3.4/dist-packages 据我了解,这意味着它是在Virtualenv之外安装的. 不确定该怎么做.阅读了一些博
我设置了一个正在工作的virtualenv,但是由于某种原因,我需要使用sudo进行sudo> mkdir的命令.显然我做了一些错误的事情.知道这可能是什么? 谢谢 解决方案 检查目录权限和所有者并给出: $ sudo chown -R me:me virtualenvdir $ sudo chmod -R a+rX virtualenvdir 更改me使用您的用户名,通常是$ user,virtualenvdir带有Virtualenv的工作目录. 其他解决方案 命令 cd test sudo virtualenv python 创建一个名为python的目录,该目录由root. 所有 drwxr-xr-x 5 root root 4096 2010-04-17 11:40 python 这会迫使您使用sudo进行简单的事物,例如在python目录中制作目录. 修复程序将是删除python目录(如有必要,请首先保存数
当我使用pip时,通常没有sudo就无法正常工作.我经常看到人们在没有sudo的情况下使用pip,所以我做错了什么? 我读到不建议使用sudo安装PIP软件包.我知道使用virtualenv我可以使用不带Sudo的PIP,但是要安装virtualenv我必须先使用sudo. 当我尝试不使用sudo安装pip时,我会得到: PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.4/dist-packages/pip' 尝试使用pip3 install flask安装烧瓶时: PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.4/dist-packages/werkzeug' 解决方案 sudo 在UNIX/Linux系统中使用作为另一个用户,使用他们的权限,例如写入某些目录的能力
尝试使用PIP安装Virtualenv $ pip install virtualenv 我获得了拒绝错误的权限 IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py' 所以我使用sudo安装virtualenv $ sudo pip install virtualenv 但随后出现警告: 目录'/users/petertao/library/caches/pip/http'或其父母 目录不是当前用户所有的,并且缓存已 禁用.请检查该目录的权限和所有者.如果 使用sudo执行PIP,您可能需要Sudo的-H标志. 目录'/users/petertao/library/caches/pip'或其父母 目录不是当前用户所有的,并且缓存轮是 禁用.检查该目录的权限和所有者.如果 使用sudo执行PIP,您可能需要Sudo的-H标志.
我正在用C(使用libpcap)写一个数据包sniffer,我无法使用Valgrind在程序中找到内存泄漏,因为它必须使用Superuser Permishions运行,因为没有此,我什至无法打开捕获的网络接口. 当我尝试使用sudo进行valgrind时,我得到了: $ valgrind sudo ./[exec] ==5211== ==5211== Warning: Can't execute setuid/setgid/setcap executable: /usr/bin/sudo ==5211== Possible workaround: remove --trace-children=yes, if in effect ==5211== valgrind: /usr/bin/sudo: Permission denied 在 # valgrind ./[exec] valgrind: ./bin/TP2: Permission denied 以及:
我在Vagrant(Ubuntu 12.04 OS)中创建了一个新的非Sudo用户(User1),并将不安全的公共密钥添加到user1授权的密钥文件中.在vagrant文件中,将默认用户添加为" user1": config.ssh.default.username = "user1" 现在Vagrant UP失败了以下错误消息: The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! mkdir -p /vagrant Stdout from the command: Stderr from the command: sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty
我在服务器上有一个Ansible 2.1.0,我在该服务器上通过 vagrant 以及PC上的部署. 角色"部署"具有: - name: upload code become: true become_user: www-data git: repo=git@bitbucket.org:****.git dest=/var/www/main key_file=/var/www/.ssh/id_rsa accept_hostkey=true update=yes force=yes register: fresh_code notify: restart php-fpm tags: fresh_code 在这种情况下,Ansible 2.1.0我有一个错误: fatal: [default]: FAILED! => {"failed": true, "msg": "Failed to set permiss
我编写了一个脚本,该脚本将作为一个串联的字符串,是用户名和项目的串联.该脚本应该根据项目字符串将(SU)切换到用户名,CD到特定目录. 我基本上想做: su $USERNAME; cd /home/$USERNAME/$PROJECT; svn update; 问题是,一旦我做一个su ...它就在那儿等.这是有道理的,因为执行流已经转移到用户.一旦我退出,其余的事情都执行,但无法按需工作. i将su验证为SVN命令,但命令失败(即,所需目录中没有更新SVN). 如何编写一个允许用户切换用户并调用SVN的脚本(除其他外)吗? 解决方案 诀窍是使用" sudo"命令而不是" su" 您可能需要添加此 username1 ALL=(username2) NOPASSWD: /path/to/svn 到您的/etc/sudoers文件 并将您的脚本更改为: sudo -u username2 -H sh -c "cd
尝试使用以下命令 安装urllib.rellib.request模块 sudo pip install urllib.request 但它返回 Downloading/unpacking urllib.request Could not find any downloads that satisfy the requirement urllib.request Cleaning up... No distributions at all found for urllib.request Storing debug log for failure in /home/mounarajan/.pip/pip.log 如何安装此模块? 解决方案 urllib.request仅在Python3分支中可用.有关更多信息,请参见以下帖子. urlllib.request in Python 2.7 其他解决方案 在Python3中,您必须使用Urllib3模块.