34

When I type Ctrl-X X (sic) in screen, the session is locked. What is the default password? Is it the same password which I use to log in to linux?

I ask because: I connect to several different remote linux servers via ssh, under various flavours of linux/unix, and have screen sessions running on all of them. When I lock the screen session and type my password, sometimes it works and on other installations it does not work and I therefore don't know what the password is (so I have to "quit" that screen session externally).

So, what is the default password of screen?

P.S.: I am never root. Version of screen used: Screen version 4.00.03 (FAU) 23-Oct-06

1
  • I expect it depends on whether screen is in a login shell, and whether login is enabled for screen
    – sehe
    Oct 7, 2011 at 9:45

4 Answers 4

12

The screen password has always been simply the system password of the user running it in my experience. the manpage says that if there's a screen lock program available, it will be used if configured so. So maybe you would need to figure out if this is the case, and how that program behaves.

7
  • For how to configure a custom lock program, see also serverfault.com/a/639406
    – tripleee
    Jan 22, 2016 at 7:27
  • 16
    And what if the user has no password and you use an SSH key to login?
    – Cerin
    Jan 27, 2016 at 0:40
  • 1
    I think then the user should not lock his screen; he might not be able to login again afterwards...
    – jpjacobs
    Jan 30, 2016 at 9:55
  • 3
    @jpjacobs: Alas, It's not always the user's choice: superuser.com/questions/344301/…
    – deltab
    Feb 5, 2016 at 14:28
  • 14
    @Cerin: Open a new SSH connection and steal the screen session from yourself.
    – valid
    Aug 21, 2016 at 10:05
40

I sometimes find myself in the same situation, on servers where I have SSH public-key login and thus no password at all (that I know), and struggle to remember what I did last time to recover.

There is no need to kill the screen. Just disconnect the terminal you are running screen in, then open a new terminal window and reattach (screen -r).

Maybe as a precaution, add bind x to your .screenrc so that the lock keystroke is unbound. In an already running screen, use ctrl-A : bind x.

4
3

the password of the user that owns the screen process.

2
  • 2
    What do you do when there is no password? I use a passwordless SSH key to login to my server and screen still asks me for a password... Feb 27, 2014 at 8:19
  • 1
    using a phrase-less ssh key (bad idea btw, look into ssh-agent) isn't the same as having no password. screen will want whatever the users password is on the remote system in /etc/shadow
    – Sirex
    Feb 27, 2014 at 17:37
3

After trying many approaches, I found that:

  • The BEST solution is adding two lines bind x bind ^x to your .screenrc file.

(Note If you are not root user, remember to add alias screen="screen -C [your .screenrc file path]" to your .bashrc file)

  • The second BEST solution is adding one line export LOCKPRG='/bin/true' to your .bashrc file. However, this method is somewhat uncommon, refer to this link

At last, thanks a lot to this guy disabling_gnu_screen_lock_screen, I just copy-paste his content here.

1
  • You don't need the -C option unless you save the .screenrc in a nonstandard place, i.e. not in your home directory.
    – tripleee
    Oct 24, 2023 at 7:37

You must log in to answer this question.