'APC PDU CLI automation over SSH

I found this script on Github for managing APC PDU from CLI, but it's using Telnet to login to APC PDU. What I'd like to do is change Telnet to SSH, but it doesn't work.

I know the command line of Telnet in the file utility.py and the part of code as below:

class APCFactory:
def build(self, host, user,  password, verbose, quiet, cli):
    self.quiet = quiet

    self.lock = APCLock(quiet)
    self.lock.lock()

    self.info('Connecting to APC @ %s' % host)
    if cli == '':
       commandline = 'telnet %s' % host

    else:
        commandline = cli.format(host=host, user=user, password=password)
    if verbose:
        print("Running '%s'" % commandline)
    child = pexpect.spawn(commandline)

But I have no idea how to change the commandline "telnet" to "ssh". Do you know the SSH commandline?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source