• 那是不是说 sshkit 或者 capistrano 都应该避免做需要 root 权限的事情?有没有避免不了的情况?

  • @Rei 这个太好了,我试试看。多谢!

  • 大家没有遇到过类似的场景吗?

  • 比如说 nginx+passenger 的环境,sshkit 登录后用 git 更新了代码后,怎样重启 nginx 服务器呢?

  • 那我用 sshkit 怎么才能执行需要 sudo 权限的命令呢?比如说重启 nginx service

  • 已经加了,正常用户登录用 sudo 没有问题。

    这是我的 code:

    on hosts, in: :parallel do |host| as('root') do blah blah blah... end end

    下面是运行时 sshkit 遇到的错误:

    /usr/local/rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status=': Exception while executing on host ec2-54-89-162-48.compute-1.amazonaws.com: if ! sudo -u root whoami > /dev/null; then echo "You cannot switch to user 'root' using sudo, please check the sudoers file" 1>&2; false; fi exit status: 1 (SSHKit::Runner::ExecuteError) if ! sudo -u root whoami > /dev/null; then echo "You cannot switch to user 'root' using sudo, please check the sudoers file" 1>&2; false; fi stdout: Nothing written if ! sudo -u root whoami > /dev/null; then echo "You cannot switch to user 'root' using sudo, please check the sudoers file" 1>&2; false; fi stderr: sudo: sorry, you must have a tty to run sudo