Accessing the current remote session using SSH

0

I have a Raspberry Pi which I use to run a Python script 24/7. I can remotely access it from my Linux laptop using SSH. But connecting to it using ssh <username>:<address> will create a new session instead of accessing the current session running in my Pi. Is there a way of using SSH so that I can see what my Python script is doing remotely and terminate and restart it remotely if necessary?

Effectively, I would like my laptop to be able to show me whatever is currently being displayed in my Pi.

gilbertohasnofb

Posted 2019-09-05T10:34:57.250

Reputation: 103

Answers

1

The easiest way of doing so is using tmux (or screen, which is an older utility).

When you ssh into your Raspberry Pi install & run tmux (no options needed) you'll get a tmux session, that you can run your Python script it, to detach press CTRL + B following with the letter D.

The script will continue running in the background, to get back just write tmux attach.

gabe

Posted 2019-09-05T10:34:57.250

Reputation: 26

Fantastic, this is exactly what I was looking for and it works as a charm. I've been using tmux for quite some time, but mainly for having multiple panes in my laptop's terminal. I wasn't aware you could attach and detach a session, much less doing so remotely via ssh. Thank you so much. – gilbertohasnofb – 2019-09-05T12:53:24.100