Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 113751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:45:06+00:00 2026-05-11T02:45:06+00:00

ADDED: This question is now, I believe, subsumed by this one: Using GNU Screen

  • 0

ADDED: This question is now, I believe, subsumed by this one: Using GNU Screen completely transparently and automatically

See also this related question:
https://superuser.com/questions/147873/ssh-sessions-in-xterms-freeze-for-many-minutes-whenever-they-disconnect

Original question:

It would be nice if there were a way to ssh to a machine and immediately reconnect to a specific screen session. You can do this:

laptop> ssh server.com screen -ls 

and it will show a list of screens available on server.com like so [1]:

123.pts-1 456.pts-2 

And then you might try to do this:

laptop> ssh server.com screen -dr pts-2 

but that fails, saying ‘Must be connected to a terminal.’ You have to ssh in first and then do the ‘screen -dr pts-2’ on server.com which is no good if you have a flaky connection and get disconnected a lot. You want to be able to resume with a simple ‘up-arrow enter’ on the laptop. (Or perhaps make it even more automatic.)

I have a rihackulous solution to this problem which I’ll post as an answer and hope it gets downvoted to oblivion in favor of the Right Way to deal with this.


Footnotes:

[1] Or, better, if you created the screen sessions with names like ‘screen -S foo‘ and ‘screen -S bar‘ then you’ll get a friendlier list like:

123.foo 456.bar 

and can reconnect with, eg, ‘screen -dr foo‘.


Mini screen tutorial, incorporating the answer to this question:

Login in to server.com and do

screen -S foo  

and then never log out of that session again. To reconnect to it from elsewhere, do

ssh -t server.com screen -dr foo 

To list available screens to reconect to:

screen -ls 

or, of course,

ssh server.com screen -ls 

to check on server.com’s available screens remotely.

I now use the following alias (tcsh), based on Jason’s answer below, to connect to a named screen if it exists or create and connect otherwise:

alias ssc 'ssh -t \!:1 'screen -S \!:2 -dr || screen -S \!:2'' 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:45:07+00:00Added an answer on May 11, 2026 at 2:45 am

    Does the -t option do what you want?

          -t      Force pseudo-tty allocation.  This can be used to execute arbi-              trary screen-based programs on a remote machine, which can be              very useful, e.g. when implementing menu services.  Multiple -t              options force tty allocation, even if ssh has no local tty. 

    So:

    laptop> ssh -t server.com screen -dr pts-2 

    This seems to work in my installation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 60k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You want float.IsNaN(...). Comparisons to NaN always return false, no… May 11, 2026 at 9:35 am
  • added an answer 'funct' must be a method with the following signature: void… May 11, 2026 at 9:35 am
  • added an answer declare @startID int, @endID int, @rowsEach int select @startID =… May 11, 2026 at 9:35 am

Related Questions

ADDED: This question is now, I believe, subsumed by this one: Using GNU Screen
After following the advice in this question successfully, I added a couple additional lines
$(document).ready(function(){ $(.txtDate).datepicker({ showOn: both, buttonImage: library/ui/datepicker/img/calendar2.gif, dateFormat: yy/mm/dd, buttonImageOnly: true }); //added this checkbox
I have added some code which compiles cleanly and have just received this Windows
I have this method: public bool CanExecute() And after 70 commits, I added an
EDIT: Modified title and added update. UPDATE : We no longer believe this is
I misremembered what the key was for this Templates table and therefore I added
In a form, I added an overload of ShowDialog(). In Visual Studio, this overload
Added: Working with SQL Server 2000 and 2005, so has to work on both.
Added : I am conducting a study for a new system we're going to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.