I am using the following python code to get a continuous log from a linux server:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('192.168.168.1', 22, username="root", password="", timeout=5)
stdin, stdout, stderror = ssh.exec_command('journalctl -f', get_pty=True)
for log in iter(stdout.readline, ""):
print(log, end="")
I would like to break this feed by any key press, but once this is running, there is no other way to stop it other than exiting the program.
Any ideas would be greatly appreciated.