Landed.
This commit is contained in:
34
secdep.py
34
secdep.py
@@ -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)
|
||||||
break
|
print(output.decode())
|
||||||
|
else:
|
||||||
|
time.sleep(0.5)
|
||||||
|
if not(channel.recv_ready()):
|
||||||
|
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:
|
||||||
|
|||||||
Reference in New Issue
Block a user