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