+def check_ssh_connection(port):
+ command = '/bin/ps aux | /bin/grep -E \'ssh.*' + str(port) + '\' | /bin/grep -v grep | wc -l';
+ output = check_output(command, shell=True)
+ print 'output: ', output
+ if int(output) == 0:
+ return False
+ else:
+ return True
+
+def try_use_rsa():
+ pub = os.getenv('HOME') + "/.ssh/id_rsa.pub"
+ if not os.path.isfile(pub):
+ # generate id_rsa.pub
+ command = 'ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -P ""'
+ print command
+ print call(command, shell=True)
+ # copy id_rsa.pub
+ command = 'sshpass -p' + PASSWORD + ' ssh-copy-id -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile /dev/null" ' + USER + '@' + SSH_SERVER
+ print command
+ print call(command, shell=True)
+
+
+