Attach screen over ssh

ssh -t remote_host screen -r
Directly attach a remote screen session (saves a useless parent bash process)

41
2009-07-23 06:15:04

1 Alternatives + Submit Alt

What Others Think

Two things, the first, I would suggest -R instead of -r (so that if it cannot find an old session it just creates a new one. ssh -t remote_host screen -R And the second thing: Why do we need the -t option?
Weboide · 478 weeks ago
-t forces a terminal to be allocated, otherwise ssh will assume you don't want one since you are only running a command and not opening a shell. Screen needs that terminal or else it won't find anything to attach to and exits.
recursiverse · 478 weeks ago
Thank you for this explanation.
Weboide · 477 weeks and 3 days ago
This can also be used with Byobu this way: ssh -t remote_host byobu -R
Weboide · 477 weeks and 3 days ago
For that matter, use screen -RR if you figure to expect multiple screen sessions.
Buzzcp · 459 weeks and 6 days ago
I prefere use RD reattach if possible with detach ssh -t remote_host screen -RD
starchox · 382 weeks and 6 days ago
Can someone explain how to create multiple sessions and run split screen for each session?
dtolj · 278 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: