Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
#28: Add experimental support for sshpass
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Nov 11, 2020
1 parent ba5e3f3 commit f5bdacc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rkd_harbor/tasks/deployment/ssh.py
Expand Up @@ -79,9 +79,15 @@ def _print_password(self, node: dict):
def _ssh(self, node: dict) -> bool:
ssh_cmd = 'ssh {}@{} -p {}'.format(node['user'], node['host'], node['port'])

if 'private_key' in node:
has_private_key = 'private_key' in node
has_password = 'password' in node

if has_private_key:
ssh_cmd += ' -i {}'.format(node['private_key'])

if not has_private_key and has_password:
ssh_cmd = 'sshpass -p "{}" '.format(node['password']) + ssh_cmd

self.sh(ssh_cmd)

return True

0 comments on commit f5bdacc

Please sign in to comment.