I like to start a server (basically a jupiter-notebook) in a screen session within an SSH, let it run and then detach immediately. doing it one by one:

screen -d -m /home/USER/anaconda3/bin/jupyter-notebook --ip HOST --port 8889 --no-browser

then detach from screen and finally disconnect from SSH. Then use the server. Everything works in this case. One can also see that the screen is running by

ssh -t USER@HOST screen -ls

Now how do I do the former in one go?

ssh -t USER@HOST "screen -d -m /home/USER/anaconda3/bin/jupyter-notebook --ip HOST --port 8889 --no-browser"

does not work. What am I doing wrong?


1 Answer 1


You are quite close, but you don't need the TTY for screen to startup - it creates it's own PTY. But you do need to put the ssh session in the background allowing the screen process to continue running, as in:

ssh -f USER@HOST 'screen -dm command'

Might also see this answer for other things you can do to the running screen session if you name it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.