def trySSHConnect(self,host, portNum):
paramiko.util.log_to_file ('paramiko.log')
try:
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh.connect(host,port=portNum,username="pi", password="raspberry")
self.ssh.get_transport().window_size = 3 * 1024 * 1024
command='python /home/pi/Desktop/control_gpio_pi/initial_check.py'
stdin,stdout,stderr = self.ssh.exec_command(command)
print('\nstout:',stdout.read())
except paramiko.AuthenticationException:
print ("Authentication failed!")
return -1
except paramiko.BadHostKeyException:
print ("BadHostKey Exception!")
return -1
except paramiko.SSHException:
print ("SSH Exception!")
self.ssh.close()
return -1
except socket.error as e:
print ("Socket error ", e)
return -1
except:
print ("Could not SSH to %s, unhandled exception" % host)
return -1
print ("Made connection to " + host + ":" + str(portNum))
return 0
control_gpio_GUI.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录