def __init__(self, opts):
        pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
        if os.path.isfile(pull_sock) and HAS_ZMQ:
            self.event = salt.utils.event.get_event(
                    'master',
                    opts['sock_dir'],
                    opts['transport'],
                    opts=opts,
                    listen=False)
        else:
            self.event = None
        self.opts = opts
        if not salt.utils.which('ssh'):
            raise salt.exceptions.SaltSystemExit('No ssh binary found in path -- ssh must be installed for salt-ssh to run. Exiting.')
        self.opts['_ssh_version'] = ssh_version()
        self.tgt_type = self.opts['selected_target_option'] \
                if self.opts['selected_target_option'] else 'glob'
        self.roster = salt.roster.Roster(opts, opts.get('roster', 'flat'))
        self.targets = self.roster.targets(
                self.opts['tgt'],
                self.tgt_type)
        # If we're in a wfunc, we need to get the ssh key location from the
        # top level opts, stored in __master_opts__
        if '__master_opts__' in self.opts:
            if self.opts['__master_opts__'].get('ssh_use_home_key') and \
                    os.path.isfile(os.path.expanduser('~/.ssh/id_rsa')):
                priv = os.path.expanduser('~/.ssh/id_rsa')
            else:
                priv = self.opts['__master_opts__'].get(
                        'ssh_priv',
                        os.path.join(
                            self.opts['__master_opts__']['pki_dir'],
                            'ssh',
                            'salt-ssh.rsa'
                            )
                        )
        else:
            priv = self.opts.get(
                    'ssh_priv',
                    os.path.join(
                        self.opts['pki_dir'],
                        'ssh',
                        'salt-ssh.rsa'
                        )
                    )
        if priv != 'agent-forwarding':
            if not os.path.isfile(priv):
                try:
                    salt.client.ssh.shell.gen_key(priv)
                except OSError:
                    raise salt.exceptions.SaltClientError(
                        'salt-ssh could not be run because it could not generate keys.\n\n'
                        'You can probably resolve this by executing this script with '
                        'increased permissions via sudo or by running as root.\n'
                        'You could also use the \'-c\' option to supply a configuration '
                        'directory that you have permissions to read and write to.'
                    )
        self.defaults = {
            'user': self.opts.get(
                'ssh_user',
                salt.config.DEFAULT_MASTER_OPTS['ssh_user']
            ),
            'port': self.opts.get(
                'ssh_port',
                salt.config.DEFAULT_MASTER_OPTS['ssh_port']
            ),
            'passwd': self.opts.get(
                'ssh_passwd',
                salt.config.DEFAULT_MASTER_OPTS['ssh_passwd']
            ),
            'priv': priv,
            'timeout': self.opts.get(
                'ssh_timeout',
                salt.config.DEFAULT_MASTER_OPTS['ssh_timeout']
            ) + self.opts.get(
                'timeout',
                salt.config.DEFAULT_MASTER_OPTS['timeout']
            ),
            'sudo': self.opts.get(
                'ssh_sudo',
                salt.config.DEFAULT_MASTER_OPTS['ssh_sudo']
            ),
            'identities_only': self.opts.get(
                'ssh_identities_only',
                salt.config.DEFAULT_MASTER_OPTS['ssh_identities_only']
            ),
        }
        if self.opts.get('rand_thin_dir'):
            self.defaults['thin_dir'] = os.path.join(
                    '/tmp',
                    '.{0}'.format(uuid.uuid4().hex[:6]))
            self.opts['ssh_wipe'] = 'True'
        self.serial = salt.payload.Serial(opts)
        self.returners = salt.loader.returners(self.opts, {})
        self.fsclient = salt.fileclient.FSClient(self.opts)
        self.thin = salt.utils.thin.gen_thin(self.opts['cachedir'],
                                             python2_bin=self.opts['python2_bin'],
                                             python3_bin=self.opts['python3_bin'])
        self.mods = mod_data(self.fsclient)
dataset/ETHPy150Open saltstack/salt/salt/client/ssh/__init__.py/SSH.__init__/original