Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overwriting ssh config bug #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#

# supported in code
host_key_path: ~/.ssh/known_hosts

# not supported in code yet
port: 22
username:
password:
pkey:
key_filename:
allow_agent: yes
look_for_kets: yes
look_for_keys: yes
compress: yes
sock:
connect_timeout:
compress: false
command_timeout:
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,15 @@
class ShellScriptHandler(BaseHandler):
""" Shell Script Handler piggybacking on paramiko SSH"""

def __init__(self, config_dir, hostname, logger_instance=None, port=22,
username=None, password=None, pkey=None, key_filename=None,
connect_timeout=None, allow_agent=True, look_for_keys=True,
compress=False, sock=None, verbose=False, debug=False,
command_timeout=None):
def __init__(self, config_dir, hostname, logger_instance=None,
verbose=False, debug=False):
"""
Constructor method responsible for reading the config and
setting up the ssh client.
Args:
config_dir - Path to config files
hostname - hostname to run the handler against
logger_instance - An instance of logger class
port - SSH port
username - Username to use for ssh
password - password for ssh
pkey - private ssh key
key_filename - ssh key file path
connect_timeout - Timeout for ssh connection
allow_agent set to False to disable connecting to the SSH agent
look_for_keys - set to False to disable searching for
discoverable private key files in ``~/.ssh/``
compress - set to True to turn on compression
sock - an open socket or socket-like object
(such as a `.Channel`) to use for communication
to the target host
verbose - verbosity flag
debug - debug flag
Raise:
Expand All @@ -63,6 +47,8 @@ def __init__(self, config_dir, hostname, logger_instance=None, port=22,
"""
BaseHandler.__init__(self, config_dir, hostname,
logger_instance, verbose)
self.hostname = hostname
self.logger_instance = logger_instance
self.debug = debug
self.verbose = verbose
self.ssh_client = None
Expand All @@ -75,31 +61,12 @@ def __init__(self, config_dir, hostname, logger_instance=None, port=22,
paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
self.config = None
self.load_config()
# initialize the config variables
self.host_key_path = None

# read in yaml configuration
for key, val in self.config.iteritems():
setattr(self, key, val)
del self.config

# Manually listing the arguments
self.hostname = hostname
self.port = port
self.username = username
self.password = password
self.pkey = pkey
self.key_filename = key_filename
self.connect_timeout = connect_timeout
self.allow_agent = allow_agent
self.look_for_keys = look_for_keys
self.compress = compress
self.sock = sock
self.verbose = verbose
self.debug = debug
self.command_timeout = command_timeout
self.logger_instance = logger_instance

def authenticate(self):
"""
Authenticate ssh connection
Expand Down