Skip to content

Commit

Permalink
Update ssh.py
Browse files Browse the repository at this point in the history
[ssh] Add User .ssh Config File Option

Resolves issue SUPDEV-137.
Adds a plugin option for the ssh module, defining whether it will or will not collect .ssh config files per user
Default for new option is True

Signed-off-by: Daniel Zhou <[email protected]>
  • Loading branch information
Daniel Zhou committed Jul 5, 2023
1 parent fc1489a commit 9e674c1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sos/report/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, IndependentPlugin
from sos.report.plugins import Plugin, IndependentPlugin, PluginOpt


class Ssh(Plugin, IndependentPlugin):
Expand All @@ -18,6 +18,12 @@ class Ssh(Plugin, IndependentPlugin):
plugin_name = 'ssh'
profiles = ('services', 'security', 'system', 'identity')

option_list = [
PluginOpt('userconfs', default=True, val_type=str,
desc=('Changes whether module will '
'collect user .ssh configs'))
]

def setup(self):

self.add_file_tags({
Expand All @@ -34,7 +40,9 @@ def setup(self):
self.add_copy_spec(sshcfgs)

self.included_configs(sshcfgs)
self.user_ssh_files_permissions()

if self.get_option('userconfs'):
self.user_ssh_files_permissions()

def included_configs(self, sshcfgs):
# Read configs for any includes and copy those
Expand Down Expand Up @@ -74,6 +82,7 @@ def user_ssh_files_permissions(self):
users_data_lines = users_data['output'].splitlines()

# Read the home paths of users in the system and check the ~/.ssh dirs
# If userconfs option is set to False, skips this
for usr_line in users_data_lines:
try:
home_dir = self.path_join(usr_line.split(':')[5], '.ssh')
Expand Down

0 comments on commit 9e674c1

Please sign in to comment.