sshkit icon indicating copy to clipboard operation
sshkit copied to clipboard

Feature: reset $HOME by using sudo -H

Open epinault opened this issue 9 years ago • 6 comments

The command for sudo

def user(&_block)
  return yield unless options[:user]
  "sudo -u #{options[:user]} #{environment_string + " " unless environment_string.empty?}-- sh -c '%s'" % %Q{#{yield}}
end

is not resetting the HOME on Ubuntu unless I add the following to the sudoer file

Defaults always_set_home

Since there is no way to override from sshkit, ( using -H) , I had to set my server to have that options. It would be nice to have the options from sshkit to not preserve the HOME

epinault avatar Mar 25 '16 20:03 epinault

This was previously discussed in #187. We'll consider a PR for this enhancement. Can you provide one?

mattbrictson avatar Mar 25 '16 21:03 mattbrictson

Surely https://github.com/capistrano/sshkit#tunneling-and-other-related-ssh-themes solves this by allowing you to add a .ssh/config to the project ?

leehambley avatar Mar 25 '16 21:03 leehambley

@leehambley Would be nicer not to have a config otherwise I would have to share that accross a team

But I ll take a look at making a pull request somehow

epinault avatar Mar 29 '16 16:03 epinault

@epinault if you read the link given, you can commit an SSH config to the repo, and SSHKit will find it, if that's not working please open a bug report.

leehambley avatar Mar 29 '16 18:03 leehambley

@leehambley Sorry my ignorance but how does ssh relate to sudo in this case? Sudo is ran with sudo -u which preserve HOME. How would the ssh config help? I need to be able to connect as a specific user (different from the machine use who runs my processes)

epinault avatar Mar 29 '16 20:03 epinault

You were not clear that:

Defaults always_set_home

Was a server-side config. Please go and adopt the closed PR if you want this feature added.

leehambley avatar Mar 30 '16 07:03 leehambley