Giter VIP home page Giter VIP logo

sshkit-sudo's People

Contributors

graaff avatar kentaroi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sshkit-sudo's Issues

Multiple Servers

If you deploy to multiple servers that require typing in a password, all the prompts get concatenated together and you end up only being able to respond to one of them (this is true even if its the same password for each server). The code that requests passwords should be protected by a mutex so you can handle each server one at a time.

capture_sudo support

I was wondering if it might be possible to implement a capture_sudo method?

I have monkey patched this as follows:

module SSHKit
  module Backend
    class Netssh < Printer
      def capture_sudo(*args)
        result = _execute!(:sudo, *args)
        result.full_stdout.sub(%r{^\[sudo\] password for .*\r\n}, '')
      end
    end
  end
end

This is quite an unpleasant implementation, but it seems to work. Is there a better way of supporting this?

Not waiting for input

Trying to use this with sshkit 1.8.1. It prompts for the sudo password but then immediately goes to new line.

Support for 'as' method

I was wondering if it would be possible to support calls to the as() method?

For some reason I couldn't work out, when execute is called, it does not call the patched _execute! method, it calls the original one, which hangs waiting for input.

I couldn't understand the class hierarchy, but is something that could be fixed?

Permission denied

my task looks like this:

  desc 'initialize certbot / letsencrypt for cloudflare'
  task :init do
    on roles(:app), in: :sequence do
      execute! :sudo, :touch, '/etc/letsencrypt/cloudflare.ini'
      execute! :sudo, :chmod, '600 /etc/letsencrypt/cloudflare.ini'
      # also tried execute! :sudo, :printf,..... 
      sudo :printf, "'dns_cloudflare_email = [email protected]\ndns_cloudflare_api_key = #{fetch(:cloudflare_api_key)}' > /etc/letsencrypt/cloudflare.ini"
    end
  end

Creating files works, but as I try to write into it, it stops.
Also tried printf without touching first
But I always get this error:


 04 sudo printf 'dns_cloudflare_email = [email protected]
dns_cloudflare_api_key = 123456789890…
      04 bash: /etc/letsencrypt/cloudflare.ini: Permission denied
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: sudo exit status: 1
sudo stdout: bash: /etc/letsencrypt/cloudflare.ini: Permission denied
sudo stderr: Nothing written
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
SSHKit::Command::Failed: sudo exit status: 1
sudo stdout: bash: /etc/letsencrypt/cloudflare.ini: Permission denied
sudo stderr: Nothing written
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/command.rb:99:in `exit_status='
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-sudo-0.1.0/lib/sshkit/sudo/backends/netssh.rb:50:in `execute_command!'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-sudo-0.1.0/lib/sshkit/sudo/backends/abstract.rb:21:in `block in create_command_and_execute!'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-sudo-0.1.0/lib/sshkit/sudo/backends/abstract.rb:21:in `tap'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-sudo-0.1.0/lib/sshkit/sudo/backends/abstract.rb:21:in `create_command_and_execute!'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-sudo-0.1.0/lib/sshkit/sudo/backends/abstract.rb:12:in `execute!'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-sudo-0.1.0/lib/sshkit/sudo/backends/abstract.rb:6:in `sudo'
config/deploy.rb:105:in `block (3 levels) in <top (required)>'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/jan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => letsencrypt:init

Did I miss something?

TypeError: superclass mismatch for class Netssh

In my Gemfile
gem 'capistrano', '3.4.0'
gem 'sshkit-sudo', github: 'kentaroi/sshkit-sudo'

In Capfile
require 'sshkit/sudo'

bundle exec cap -T results in
TypeError: superclass mismatch for class Netssh in require

undefined method `noecho' for #<IO:<STDIN>>

I'd encountered this error and resolved require 'io/console'.
Do this gem need io/console?
I suppose It should be wrotten in README.
Or is it a common knowledge in ruby?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.