Connections.py 文件源码

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

项目:vanilla-nodebb-importer 作者: Linux-statt-Windows 项目源码 文件源码
def __makeConnection(self, host, user, pw):
        """
        Private Method to create a SSH connection.

        @param      host <string>
                    The server host name or IP-Address.

        @param      user <string>
                    The user name for the SSH connection.

        @param      pw <string>
                    The password for the SSH connection.

        @return     sshClient <SSH Connection>
                    A SSH connection instance.
        """

        sshClient = paramiko.SSHClient()
        sshClient.load_system_host_keys()
        sshClient.set_missing_host_key_policy(paramiko.WarningPolicy())

        try:
            sshClient.connect(host, username=user, password=pw)
        except paramiko.SSHException:
            print("\033[31mConnection Error !!!")
            print("Something is going wrong during the SSH connection.\033[0m\n")
            sys.exit(1)

        return sshClient
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号