sshfw.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:pyability 作者: syedur-rahman 项目源码 文件源码
def login(self, switch):
        """ login
        logs into specified switch """

        # set up ssh client
        ssh_setup = paramiko.SSHClient()

        # add missing host key policy (set as auto)
        ssh_setup.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        # connect to switch
        ssh_setup.connect(
            switch, 
            username=self.user, 
            password=self.user_pw, 
            look_for_keys=False, 
            allow_agent=False,
            )
        # set up transport channel for session
        transport = ssh_setup.get_transport()

        # invoke session
        self.ssh_session = transport.open_session()

        # set up for interactive mode, multiple commands - pty
        self.ssh_session.get_pty()

        # invoke session's shell
        self.ssh_session.invoke_shell()

        # keep session active with parameters while class is initialized
        self.ssh_session.keep_this = ssh_setup
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号