Forum Discussion

sabraham's avatar
Occasional Contributor
4 years ago

Connecting to SSH using TestComplete (Used Paramiko but is erroring out)

Hi all,

I would like to establish a SSH connection using Test Complete.

My scripts are in Python so Paramiko was the candidate that I wanted to proceed with.

I downloaded the package from and saved it to the below path ->

C:\Program Files (x86)\SmartBear\TestComplete 14\Bin\Extensions\Python\Python36\Lib\

My script:-

import paramiko
import sys

sys.path.insert(0,"C:\\Program Files (x86)\\SmartBear\\TestComplete 14\\Bin\\Extensions\\Python\\Python36\\Lib")

def test02():
host = ""
port = 22
username = "demo"
password = "password"
command = "ls"

ssh = paramiko.SSHClient()
ssh.connect(host, port, username, password)

stdin, stdout, stderr = ssh.exec_command(command)
lines = stdout.readlines()


When I run the script, I get an error as below :-


Python runtime error.
ImportError: cannot import name '_bcrypt'


Please can someone help on the same.

Thanks in advance.

  • sonya_m  AlexKaras 


    Finally I was able to implement Paramiko on Test Complete (Python 3.6) successfully.


    Please find the instructions below (Readability is better if the instructions file is opened using Notepad++) :-


    Note:- The understanding is that Test Complete is running Python 3.6
                Running Test Complete from the Desktop shortcut defaults to opening the 64-bit version of Test Complete.
                The instructions here explains how to Implement Paramiko on the 64-bit version of Test Complete.


    (1) Copy all the contents from "Required Libs for Paramiko" and paste it to the below path:-
    C:\Program Files (x86)\SmartBear\TestComplete 14\x64\Bin\Extensions\Python\Python36\Lib

    (2) Copy the file "_cffi_backend.cp36-win_amd64.pyd" from the folder "Copy the content to DLL" and paste it to the below path:-
    C:\Program Files (x86)\SmartBear\TestComplete 14\x64\Bin\Extensions\Python\Python36\DLLs

    (3) Done, the required files for Paramiko have been successfully loaded.


    (4) Please find a sample Paramiko script below. Feel free to use any script as desired.




    import paramiko
    def execSSH(host, user, passwd, command, filename):
      ssh_client = paramiko.SSHClient()
      #Establishes a SSH connection with the given details.
      ssh_client.connect(hostname=host, username=user, password=passwd)
      #The SSH commands are executed one by one. Please note that only the last command's 
      #output is saved to the output file. The file is currently saved to the current 
      #present-working-directory (pwd) of the remote server.
      stdout = ssh_client.exec_command(command + " > " + filename)
      #SFTP connection is opened. This is for copying the file from the remote server to our 
      #local machine.
      sftp_client = ssh_client.open_sftp()
      #The created output file is copied from the remote server to our local machine.
      #Please note that the remote-server-path is the present-working-directory (pwd), if 
      #you give otherwise the file-save will fail.
      #sftp_client.get("<remote-server-path>" + filename, "<local-machine-path>" + filename)
      sftp_client.get("/mnt/AMPBackup/" + filename, "C:\\Users\sabraham\Desktop\\" + 
      #The output file is deleted from the remote server since it was copied over to the 
      #local machine.
      sftp_client.remove("/mnt/AMPBackup/" + filename)
      #Close the SFTP and SSH connections
    if __name__ == '__main__':
      #The variable command holds the various SSH commands we would like to execute one-by- 
      #one on the remote server.
      #Syntax:- command = 'command_1; command_2; command_3; etc....'
      command = 'cd /mnt/AMPBackup/; ls'
      #SSH function call
      execSSH("", "user_auth", "pass1",command,"outputfile.txt")




8 Replies

  • AlexKaras's avatar
    Champion Level 3



    Just a wild guess, but can't this be due to some dependency been missed?


    • sabraham's avatar
      Occasional Contributor

      Hi Alex,

      I have placed the libraries such as "cryptography" and "bcrypt" in the Test Complete path (C:\Program Files (x86)\SmartBear\TestComplete 14\Bin\Extensions\Python\Python36\Lib\).

      I do not know from where can I get a "_bcrypt" library file.