This commit is contained in:
2023-03-16 22:48:56 +02:00
parent b935f630e9
commit 8cdfc98555

View File

@@ -1443,22 +1443,28 @@ def ssh():
port = 22 port = 22
username = "secdep" username = "secdep"
sshkey = SECDEP_SSH_PRIVATE_KEY sshkey = SECDEP_SSH_PRIVATE_KEY
try:
ssh = paramiko.SSHClient() ssh = paramiko.SSHClient()
ssh.load_system_host_keys() ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, port=port, username=username, key_filename=sshkey) ssh.connect(ip, port=port, username=username, key_filename=sshkey)
channel = ssh.get_transport()
if channel is not None:
channel = channel.open_session()
channel.get_pty()
channel.invoke_shell()
while True: while True:
try: command = input('$> ')
prompt = input("$> ") if command == 'exit': break
if prompt == "exit": break channel.send((command + "\n").encode())
stdin, stdout, stderr = ssh.exec_command(prompt) while True:
print(stdout.read().decode()) if channel.recv_ready():
except KeyboardInterrupt: output = channel.recv(1024)
print(output.decode())
else:
time.sleep(0.5)
if not(channel.recv_ready()):
break break
ssh.close() ssh.close()
except Exception as ex:
print(str(ex))
# If -I -S or -G is passed, provider must be passed as well # If -I -S or -G is passed, provider must be passed as well
if args.listimages or args.listsizes or args.listlocations: if args.listimages or args.listsizes or args.listlocations: