Index
Starting Linux Screen
To start a screen session, simply type screen in your console:
screen
This will open a screen session, create a new window, and start a shell in that window.
Now that you have opened a screen session, you can get a list of commands by typing:
Ctrl+a ?
Starting Named Session
Named sessions are useful when you run multiple screen sessions. To create a named session, run the screen command with the following arguments:
screen -S session_name
It’s always a good idea to choose a descriptive session name.
Working with Linux Screen Windows
When you start a new screen session, it creates a single window with a shell in it.
You can have multiple windows inside a Screen session.
To create a new window with shell type c, the first available number from the range 0...9 will be assigned to it.
Below are some most common commands for managing Linux Screen Windows:
- c Create a new window (with shell).
- " List all windows.
- 0 Switch to window 0 (by number).
- A Rename the current window.
- S Split current region horizontally into two regions.
- | Split current region vertically into two regions.
- tab Switch the input focus to the next region.
- Ctrl+a Toggle between the current and previous windows
- Q Close all regions but the current one.
- X Close the current region.
Detach from Linux Screen Session
You can detach from the screen session at any time by typing:
d
The program running in the screen session will continue to run after you detach from the session.
Reattach to a Linux Screen
To resume your screen session use the following command:
screen -r
In case you have multiple screen sessions running on your machine, you will need to append the screen session ID after the r switch.
To find the session ID list the current running screen sessions with:
screen -ls
There are screens on: 10835.pts-0.linuxize-desktop (Detached) 10366.pts-0.linuxize-desktop (Detached) 2 Sockets in /run/screens/S-linuxize.If you want to restore screen 10835.pts-0, then type the following command:
screen -r 10835
Customize Linux Screen
When screen is started, it reads its configuration parameters from /etc/screenrc and ~/.screenrc if the file is present. We can modify the default Screen settings according to our preferences using the .screenrc file.
Here is a sample ~/.screenrc configuration with customized status line and few additional options:
# Turn off the welcome message
startup_message off
# Disable visual bell
vbell off
# Set scrollback buffer to 10000
defscrollback 10000
# Customize the status line
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'When you can't re-attach to your screen session after a lost connection
In some cases, your previous screen session may not have detached properly when you lost your connection. If this happens, you can detach your session manually.
To see your existing screen sessions, enter:
screen -listThis will display a list of your current screen sessions. For instance, if you had one attached and one dead screen, you would see:
There are screens on: 25542.pts-28.hostname (Dead ???) 1636.pts-21.hostname (Attached) Remove dead screens with 'screen -wipe'. 2 Sockets in /tmp/screens/S-username.To detach an attached screen, enter:
screen -DIf you have more than one attached screen, you can specify a particular screen to detach. For example, to detach the screen in the above example, you would enter:
screen -D 1636.pts-21.hostnameOnce you've done this, you can resume the screen by entering the screen -r command.
(In the above example, the dead screen isn't causing problems, but you should probably enter the screen -wipe command to get rid of it.)
SSH sicuro senza password (quick)
On your local machine, go to terminal and type the following:
$ cd ~/.ssh $ ssh-keygen -t rsa
# here just hit enter multiple times till terminal stop asking you any questions
Choose no passphrase when asked and accept the default filename of id_rsa
$ scp id_rsa.pub <user>@<yourhost>:.ssh/authorized_keys
Provide your password when asked and that’s the last time you’ll have to do it!
SSH sicuro senza password
http://www.debianitalia.org/modules/wfsection/article.php?articleid=99
SSH sicuro senza password | |
|
|
Introduzione
Creazione chiave privata/pubblica
~$ ssh-keygen -t dsa
Installazione chiave pubblica
~$ scp .ssh/id_dsa.pub 192.168.10.2:~/.ssh/
~$ ssh 192.168.10.2
~$ scp file 192.168.10.2:~
Conclusioni
|
Tunnell SSH
ssh -L 8080:172.16.1.42:80 -L 3389:172.16.1.41:3389 user@pubblic_IP -p 222
sintassi:
-L local port : internal IP : port
tunnel criptato tra host in internet e firewall, in chiaro tra firewall e ip interno (come in LAN)