Git Product home page Git Product logo

sshkit-backends-netssh_global's Introduction

SSHKit Backends Netssh Global

SSHKit Backends Netssh Global is a backend to be used in conjunction with Capistrano 3 and SSHKit to allow global configuration to be set. For example, all commands can be run under a different user or folder - without modifying the command.

This is designed to make it possible for Capistrano 3 to deploy on systems where users login as one identity and then need to sudo to a different identity for each command.

This works globally so that default tasks will automatically sudo and cd without modification. This allows the default tasks to be used in this kind of setup without them being altered.

If a task specifically sudo's or cd's then the global setting will not take effect.

In some setups the ssh agent also needs to be forwarded (such as git clone). Here the setting ssh_commands can be set to automatically forward the ssh agent to the sudo user for certain commands.

To run tests

To setup an OSX machine to run the tests, install Homebrew then:

brew tap Homebrew/bundle
brew bundle
vagrant up --provision
bundle
rake

Usage

require 'sshkit/backends/netssh_global'

set :sshkit_backend, SSHKit::Backend::NetsshGlobal

SSHKit::Backend::NetsshGlobal.configure do |config|
  config.owner        = 'bob'       # Which user to sudo as for every command
  config.directory    = '/home/bob' # Can be specified if it is important to default commands to run in a 
                                    # certain directory. This can be used to overcome permission problems when
                                    # sudo'ing
  config.ssh_commands = [:git]      # Setting for which commands require SSH forwarding
  config.shell        = 'bash -l'   # Setting that allows the shell that sudo runs to be overriden
end

# Per host configuration
Host.new("example.com").tap do |h|
  h.properties.owner        = 'fred'
  h.properties.directory    = '/home/fred'
  h.properties.ssh_commands = [:git, :bundle]
end

Credits

The code and test suite are built on top of SSHKit.

sshkit-backends-netssh_global's People

Contributors

berkos avatar bliof avatar dependabot[bot] avatar gcapizzi avatar sgerrand avatar theozaurus avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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  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

sshkit-backends-netssh_global's Issues

Bug or not documented feature

namespace :wtf do
  task :user do
    on roles(:web) do
      execute 'echo $USER' # root
      execute :echo, '$USER' # owner
      execute '', 'echo $USER' # owner
    end
  end
end

Sudo in task not working

The documentation says

If a task specifically sudo's or cd's then the global setting will not take effect.

But that does not seem to be the case. I log in as user a and need to run most commands as user b. Simply setting config.owner to b is enough to make that work.

I also need to run some commands using sudo and only user a is in my sudoers file.

This plugin should ignore tasks that already start with sudo.

The task I'm having problems with is:

task :unmonitor do
  on roles(:app) do
    sudo :monit, 'unmonitor', fetch(:application)
  end
end

Required sshkit conflicts

The actual version of the plugin conflicts with the sshkit dependency of the lastest version of Capistrano (3.5.0).

Gem::ConflictError: Unable to activate sshkit-backends-netssh_global-0.0.1, because sshkit-1.10.0 conflicts with sshkit (= 1.7.1)
/home/lucas.diedrich/projetos/teste_capis/Capfile:7:in `<top (required)>'
Gem::ConflictError: Unable to activate sshkit-backends-netssh_global-0.0.1, because sshkit-1.10.0 conflicts with sshkit (= 1.7.1)

Cant seem to get this to work

I have require 'sshkit/backends/netssh_global' in my capfile and then in my deploy.rb I have:

SSHKit.config.backend = SSHKit::Backend::NetsshGlobal
SSHKit::Backend::NetsshGlobal.configure do |config|
  config.owner        = 'username'
  config.directory    = '/home/username'
  config.ssh_commands = [:git]
  config.shell        = 'bash -l'
end

But it doesnt seem to make a difference to the username used to run the default capistrano commands. Is there anything I am missing?

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.