How to create virtual terminal from a single ssh connection?
How to have multiple terminal screen from a single ssh connection?
How to disconnect / reconnect back with running download jobs after disconnecting from ssh?
How to re-establish pending jobs and restore screen after exiting ssh connection?
How to detach and reattach ssh connections?
How to know which tty does your current ssh connection is connected to?
How to restrict root logins via ttys and vcs?
Here's a quick and brief way on how to do this stuff.
Screen is nice linux terminal manager and utility on accomplishing simple above mentioned functions. This terminal screen manager is installed along with default server configuration tools group package.
In redhat-based distro like Fedora and CentOS, there is a file called /etc/securetty which is root writable and readable only. This file lists down all valid and allowed ttys and virtual consoles where the root user is only allowed to login into. Usually, atleast one tty should be present with this file to give way for physical and direct server root logins. That means, if you only have tty2 listed from this file, root cannot login directly via tty1 or to any other known ttys or even pressing key combinations Ctrl+F1 to Ctrl+F6. Ctrl+F7 brings you to X.
Now, how to know which tty your currently logged in user logs into?
# tty
Querying linux for all logged in users would give you a hint like so
# who
# w
How to know if there is an existing ssh screen session active inside the linux. Here's how to verify it, issue as root:
# screen -ls
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No Sockets found in /var/run/screen/S-root.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, from the server, create a new screen terminal session USING root for example, simply issue and follow the following root commands:
# screen
# clear
# echo REMEMBER THIS SCREEN VERTITO?
and verify for any active screen terminal session again by doing so
# screen -ls
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is a screen on:
2374.pts-3.ver (Attached)
1 Socket in /var/run/screen/S-root.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As you can see, there is an existing single attached screen terminal currently active, which is your current screen session at this point.
Now, close your current terminal session by hitting X button for closing the terminal button or hitting Ctrl+F4 forcibly. DO NOT HIT Ctrl+D or even typing logout and exit from your ssh connection. Doing so, would disconnect your screen session and your ssh session.
Try to login back via ssh to same remote host. Issue the following as root:
# screen -ls
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is a screen on:
3300.pts-3.ver (Detached)
1 Socket in /var/run/screen/S-root.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since you forcibly closed your ssh session, you have left your screen terminal session in a detached mode, as you can see from above results.
How to re-establish back the detached screen session using current ssh connection?
You are already aware of an existing detached screen session, all you need to do is to reattached you ssh session with that screen session. Just follow these steps:
# screen -d -r
You should be back with your previous screen session and terminal. Noticed the lines
REMEMBER THIS SCREEN VERTITO?
which was echoed to the screen before you forcibly closed your ssh connection?
This can be handy on different occassion and situations. Let me give you some ideas.
Supposed that you are currently downloading 4GB of DVD ISO image file from the office and your wife called you over the phone to come home earlier for a sweet dinner outside? Use screen utility before issuing your download command. This way, you left the process of downloading active. And when you try to ssh back from your house remotely, you can reattach back to that same screen session (with same screen display) like the above demonstration.
Another instance.
You are a compile geek trying to modify your kernel source settings from your office area. Assuming that it would take 2 hours for the kernel compilation to be completed. This is another way to launch a screen session from your office desktop one step before you issue your compilation commands scripts. Later on and from a different location, simply reattach back to that detached and active screen session.
Screen command makes use of /etc/screenrc as its conf file.
Some screen shortcut keys:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ctrl+a is the control key for screen
Ctrl+a c = creates a nwe screen session
Ctrl+a n = next screen session
Ctrl+a p = previous screen session
Ctrl+a " = list all screen session for selection
Ctrl+a A = assign a name for current screen session
Ctrl+a w = shows terminal session names using terminal title bar
Ctrl+a
= when using keyboard , arrow buttons,pg down/up, hit space to begin copy,and space
to end buffer copy. alternatively, use mouse right click copy/paste.
=
Ctrl+a d = detaches current screen session
Ctrl+a 1 = first active screen session
Ctrl+a 2 = second active screen session and so on..
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# screen -ls = list out screen sessions
# screen -d -r = reattach a session
See the man page for more.
# man screen
Hope you enjoy this screen utility session like I do.
Did you try these during screen session? Noticed something different?
# who
# w
Cheers
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
August
(95)
- KCron - GUI task scheduler
- Linux backups powered by Tar
- INQ7 front page image retrieval
- using wget for data and file transfers
- BibleTime - Bible study from Linux howto
- human readable DVD/CD drive technical details
- sound-juicer - alternative audio CD ripper install
- Stellarium - watch the sky from Linux
- Munin - monitor linux hosts install howto
- blocking yahoo chat messenger
- string manipulation using cut linux command
- graphing skystream DVB receiver's Eb/No and signal...
- BZFlag - 3D multi-player tank game install howto
- screenshot and snapshot creations howtos
- string parsing using bash
- grep multiple character from string or file
- enable and disable of telnet service
- grep multiple strings from a file
- remove spaces from filenames
- ISO creation and CD/DVD burning from terminal
- send a message to user's terminal
- retrieve GMail emails via terminal using fetchmail
- more of activating and deactivating network card
- set new mysql password
- TIP: enable thumbnail display images from apache
- monitor large mailbox users
- using the linux yes command
- string manipulation using tr linux command
- install and play 2D chess game in linux
- more firefox tips and tricks
- recover root password on linux
- establish ssh connection from different port
- uniq linux command
- remove blank lines using grep or sed
- date and time sync via NTP server howto
- who am I
- delete spam email and folder regularly howto
- hello world bash and perl script
- passwordless rdesktop session with XP howto
- force VGA screen resolution and screen mode
- RealPlayer 10 for linux install howto
- Grip - CD ripper install howto
- Banshee - music management and playback
- gnome music applet install howto
- Pirut and yum-updatesd - software management
- Alacarte - editing panel menus install howto
- access NTFS drive in Fedora
- FileLight - graphical disk usage and statistics
- TestDisk- partition tool install howto
- using /dev/null in linux terminal
- yahoo messenger in fedora install howto
- check and repair MS-DOS file systems howto
- using fdformat and mkdosfs from terminal
- Tremulous - Quake 3 install howto
- block consecutive IP address using scripts
- using floppy linux command from terminal
- display word or text file in reversed pattern
- convert a file to equivalent hex/binary code
- spell check text file from terminal
- create screen timer from linux howto
- recreate deleted /dev/null
- harddisk monitoring using smartctl
- bind ssh to selected IP address
- restrict su command to superuser only
- thunderbird install howto
- dovecot POP3/POP3S server with SSL/TLS install howto
- qpopper POP3 server install howto
- my other linux pages
- more ssh log parsing and monitoring
- checking daemon service bash script
- HTML CHM help file viewer install howto
- du - the disk usage linux command howto
- gnome language translator install howto
- display linux memory information howto
- display the number of processor howto
- 3d tabletennis game install howto
- Nokia N70 on Fedora via USB data cable
- Fedora 7 as guest host from VirtualBox
- at - jobs scheduling howto
- Nokia 70 linux connection via bluetooth dongle howto
- crontab - jobs scheduling howto
- managing daemon services howto
- create your own linux OS distro howto
- kernel devel headers install howto
- more multimedia browser plugins install howto
- numlock on with X install howto
- Fedora and RHEL differences
- create virtual terminals with single ssh connection
- virtual CentOS using VMWare 5.5.4 install howto
- VMware workstation 5.5.4 install howto
- 50 quick linux command tips part 4
- 5 SysAds permanent static route story
- ssh log parsing and monitoring
- removable drives, devices and media preferences
- gnome-blog desktop blogging install howto
-
▼
August
(95)
Monday, August 6, 2007
create virtual terminals with single ssh connection
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment