def cmd_ssh(self, argv, help):
parser = argparse.ArgumentParser(<EOL>prog="<STR_LIT>" % self.progname,<EOL>description=help,<EOL>)<EOL>instances = self.get_instances(command='<STR_LIT>')<EOL>parser.add_argument("<STR_LIT>", nargs=<NUM_LIT:1>,<EOL>metavar="<STR_LIT>",<EOL>help="<STR_LIT>",<EOL>choices=sorted(instances))<EOL>parser.add_argument("<STR_LIT>", nargs=argparse.REMAINDER,<EOL>help="<STR_LIT>")<EOL>iargs = enumerate(argv)<EOL>sid_index = None<EOL>user = None<EOL>for i, arg in iargs:<EOL><INDENT>if not arg.startswith('<STR_LIT:->'):<EOL><INDENT>sid_index = i<EOL>break<EOL><DEDENT>if arg[<NUM_LIT:1>] in '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>elif arg[<NUM_LIT:1>] in '<STR_LIT>':<EOL><INDENT>value = iargs.next()<EOL>if arg[<NUM_LIT:1>] == '<STR_LIT:l>':<EOL><INDENT>user = value[<NUM_LIT:1>]<EOL><DEDENT>continue<EOL><DEDENT><DEDENT>if sid_index is None:<EOL><INDENT>parser.parse_args([])<EOL><DEDENT>else:<EOL><INDENT>sid = argv[sid_index]<EOL>if '<STR_LIT:@>' in sid:<EOL><INDENT>user, sid = sid.split('<STR_LIT:@>', <NUM_LIT:1>)<EOL><DEDENT>parser.parse_args([sid])<EOL><DEDENT>instance = instances[sid]<EOL>if user is None:<EOL><INDENT>user = instance.config.get('<STR_LIT:user>')<EOL><DEDENT>try:<EOL><INDENT>ssh_info = instance.init_ssh_key(user=user)<EOL><DEDENT>except (instance.paramiko.SSHException, socket.error) as e:<EOL><INDENT>log.error("<STR_LIT>")<EOL>log.error(unicode(e))<EOL>log.error("<STR_LIT>")<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>client = ssh_info['<STR_LIT>']<EOL>client.get_transport().sock.close()<EOL>client.close()<EOL>argv[sid_index:sid_index + <NUM_LIT:1>] = instance.ssh_args_from_info(ssh_info)<EOL>argv[<NUM_LIT:0>:<NUM_LIT:0>] = ['<STR_LIT>']<EOL>os.execvp('<STR_LIT>', argv)<EOL>
Log into the instance with ssh using the automatically generated known hosts