How to effectively use screen and SSH?

Tobias Kienzler

I'd like to configure SSH and screen such that a login will always reattach to a screen session. Ideally, that session would not quit but detach when I press C-d. How can this be achieved? And what other useful settings are there to make my SSH-life easier?

daemonofchaos

I just did the following for all of my servers so that when I connect via SSH I am automatically put into a Screen session.

Add the following to the ~/.bashrc for your user accounts:

# Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen
# if we're coming from a remote SSH connection, in an interactive session
# then automatically put us into a screen(1) session.   Only try once
# -- if $STARTED_SCREEN is set, don't try it again, to avoid looping
# if screen fails for some reason.
if [ "$PS1" != "" -a "${STARTED_SCREEN:-x}" = x -a "${SSH_TTY:-x}" != x ] 
then
  STARTED_SCREEN=1 ; export STARTED_SCREEN
  screen -RR -S main || echo "Screen failed! continuing with normal bash startup"
fi
# [end of auto-screen snippet]

This will start a screen session named main if it doesn't exist or reconnect to it if it does. This was done because I have several other screen sessions running detached for various services and didn't want to connect to them.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to use Cmd's tab autocomplete effectively?

분류에서Dev

How login a user on desktop screen using ssh

분류에서Dev

ssh -> screen -> ssh - how to kill remote screened ssh without killing original ssh session

분류에서Dev

How to use EGit with SSH on Windows?

분류에서Dev

How to use collections.deque most effectively (popleft vs. appendleft)

분류에서Dev

How to configure ssh to use different key?

분류에서Dev

how to use emacs tramp with ssh remote to server

분류에서Dev

How to effectively convert between NSNumber and NSString objects

분류에서Dev

How to disable "effectively" windows 10 access to camera?

분류에서Dev

How to Use IsolatedStorage to Set Lock Screen Background in Windows Phone 8

분류에서Dev

How do I obtain the output from a program that uses screen redrawing for use in a terminal screen scraper?

분류에서Dev

How to use a non-default login shell for ssh login

분류에서Dev

How to effectively drive 12 displays to preserve resolution & aspect ratio

분류에서Dev

How can I effectively save a tree structure in a database?

분류에서Dev

SSH to access remote screen without X

분류에서Dev

what is the use of resolve and how to send data from pop up screen to view in angular js?

분류에서Dev

How do you use the TTY (without X server) on one screen, and X on the other?

분류에서Dev

How to use VLC to watch a file (while it is being modified) on a SSH server (using sftp or smth else)?

분류에서Dev

What is the use for ssh keys with no passphrase?

분류에서Dev

How to recover splash screen

분류에서Dev

How to let screen time out on sign in screen

분류에서Dev

How to effectively re-start the preview having taken a photo inside an Android app?

분류에서Dev

how to umount /home in ssh?

분류에서Dev

How to organise SSH keys?

분류에서Dev

Use different images depending on screen orientation

분류에서Dev

How to find and change the screen DPI?

분류에서Dev

How to restrict tablet screen orientation

분류에서Dev

How to disable screen dimming in 14.04?

분류에서Dev

how to resize horizontally a screen region

Related 관련 기사

  1. 1

    How to use Cmd's tab autocomplete effectively?

  2. 2

    How login a user on desktop screen using ssh

  3. 3

    ssh -> screen -> ssh - how to kill remote screened ssh without killing original ssh session

  4. 4

    How to use EGit with SSH on Windows?

  5. 5

    How to use collections.deque most effectively (popleft vs. appendleft)

  6. 6

    How to configure ssh to use different key?

  7. 7

    how to use emacs tramp with ssh remote to server

  8. 8

    How to effectively convert between NSNumber and NSString objects

  9. 9

    How to disable "effectively" windows 10 access to camera?

  10. 10

    How to Use IsolatedStorage to Set Lock Screen Background in Windows Phone 8

  11. 11

    How do I obtain the output from a program that uses screen redrawing for use in a terminal screen scraper?

  12. 12

    How to use a non-default login shell for ssh login

  13. 13

    How to effectively drive 12 displays to preserve resolution & aspect ratio

  14. 14

    How can I effectively save a tree structure in a database?

  15. 15

    SSH to access remote screen without X

  16. 16

    what is the use of resolve and how to send data from pop up screen to view in angular js?

  17. 17

    How do you use the TTY (without X server) on one screen, and X on the other?

  18. 18

    How to use VLC to watch a file (while it is being modified) on a SSH server (using sftp or smth else)?

  19. 19

    What is the use for ssh keys with no passphrase?

  20. 20

    How to recover splash screen

  21. 21

    How to let screen time out on sign in screen

  22. 22

    How to effectively re-start the preview having taken a photo inside an Android app?

  23. 23

    how to umount /home in ssh?

  24. 24

    How to organise SSH keys?

  25. 25

    Use different images depending on screen orientation

  26. 26

    How to find and change the screen DPI?

  27. 27

    How to restrict tablet screen orientation

  28. 28

    How to disable screen dimming in 14.04?

  29. 29

    how to resize horizontally a screen region

뜨겁다태그

보관