Просто добавьте порт после хоста, и вы установите:
ssh.connect('MASKED', 22, username='MASKED',password='MASKED')
Кстати, как сказал robots.jpg, метод connect ничего не возвращает.Вместо того, чтобы возвращать значения, он вызывает исключения .
Вот более полный пример:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import paramiko, os, string, pprint, socket, traceback, sys
time_out = 20 # Number of seconds for timeout
port = 22
pp = pprint.PrettyPrinter(indent=2)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
file = open( "file.txt", "r" )
# NOTE: The file contains:
# host user current_password
array = []
for line in file:
array = string.split(line.rstrip('\n'),)
# pp.pprint(array)
try:
ssh.connect(array[0], port, array[1], array[2], timeout=time_out)
print "Success!! -- Server: ", array[0], " Us: ", array[1]
except paramiko.AuthenticationException:
print "Authentication problem -- Server: ", array[0], " User: ", array[1]
continue
except socket.error, e:
print "Comunication problem -- Server: ", array[0], " User: ", array[1]
continue
ssh.close()
file.close()
Код требует некоторой полировки, но он выполняет свою работу.