Recent Changes - Search:


Deb /

Monitoring

Deb.Monitoring History

Show minor edits - Show changes to output

October 12, 2010, at 02:58 PM by 80.13.23.147 -
Added lines 43-51:
Deleted lines 55-56:
!! Automatic 'screen' on remote logins
October 12, 2010, at 02:30 PM by 80.13.23.147 -
Deleted line 97:
October 12, 2010, at 02:29 PM by 80.13.23.147 -
Changed line 44 from:
''Copie de http://taint.org/wk/RemoteLoginAutoScreen''
to:
''Copie de http://taint.org/wk/RemoteLoginAutoScreen (ci-dessous)''
Changed lines 52-56 from:
Bonus features in the screenrc:
* color terminal-window support
* logging of the entire session, to a datestamped logfile under $HOME/lib/screen-logs

to:
Bonus features in the ''screenrc'' :
* color terminal-window support
* logging of the entire session, to a datestamped logfile under $HOME/lib/screen-logs
October 12, 2010, at 02:29 PM by 80.13.23.147 -
Added lines 43-100:
----
''Copie de http://taint.org/wk/RemoteLoginAutoScreen''
----

!! Automatic 'screen' on remote logins

If you routinely log into one or more remote systems using SSH, and have a flaky internet connection or an incompetent ISP, you probably already know about screen's ability to detach and reattach sessions.
However, you still have to manually type screen -r to resume a detached session, each time -- and sometimes you'll forget, start working in an SSH session, get logged out, and lose your state.
Here's the next step -- automatic screen-sessions for any remote logins.
Bonus features in the screenrc:
* color terminal-window support
* logging of the entire session, to a datestamped logfile under $HOME/lib/screen-logs


Add these lines at the top of ~/.bashrc on the target host:
[@
# 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
[ -d $HOME/lib/screen-logs ] || mkdir -p $HOME/lib/screen-logs
sleep 1
screen -RR && exit 0
# normally, execution of this rc script ends here...
echo "Screen failed! continuing with normal bash startup"
fi
# [end of auto-screen snippet]
@]

Create ~/.screenrc on the target host, containing:
[@
# see http://www4.informatik.uni-erlangen.de/~jnweiger/screen-faq.html
# support color X terminals
termcap xterm 'XT:AF=\E[3%dm:AB=\E[4%dm:AX'
terminfo xterm 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX'
termcapinfo xterm 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX:hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
termcap xtermc 'XT:AF=\E[3%dm:AB=\E[4%dm:AX'
terminfo xtermc 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX'
termcapinfo xtermc 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX:hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'

# auto-screen support; see http://taint.org/wk/RemoteLoginAutoScreen
# detach on hangup
autodetach on
# no startup msg
startup_message off
# always use a login shell
shell -$SHELL

# auto-log
logfile $HOME/lib/screen-logs/%Y%m%d-%n.log
deflog on
@]

Note: if you just want the auto-screen feature, the middle 7 lines are the important bit; you can probably omit the "color X terminals" and "auto-log" stanzas if you like.
October 12, 2010, at 01:42 PM by 80.13.23.147 -
Changed lines 5-6 from:
to:
* http://taint.org/wk/RemoteLoginAutoScreen
October 12, 2010, at 12:17 PM by 80.13.23.147 -
Changed lines 37-41 from:
to:
October 12, 2010, at 12:09 PM by 80.13.23.147 -
Changed lines 14-15 from:
to:
* @todo [[Deb/process-resource-monitor]]
October 12, 2010, at 12:01 PM by 80.13.23.147 -
Changed line 29 from:
echo "$reason || `whoami` login on `date` : `who`" | mail -s "[Login] `hostname` - `whoami` access from `who | awk '{print $5}'`" external-mail@domain.tld
to:
echo -e "`whoami` login on `date`\n\nReason given on prompt :\n$reason\n\nActive connexions :\n`who`\n\n" | mail -s "[Login] `hostname` - `whoami` access from `who | awk '{print $5}'`" external-mail@domain.tld
October 12, 2010, at 11:55 AM by 80.13.23.147 -
Changed lines 25-33 from:
to:
October 12, 2010, at 11:44 AM by 80.13.23.147 -
Added lines 15-18:
!! Modifier le texte d'acceuil au login shell

@@vim /etc/motd@@
October 12, 2010, at 11:38 AM by 80.13.23.147 -
Changed line 21 from:
to:
October 12, 2010, at 11:37 AM by 80.13.23.147 -
Deleted line 18:
Deleted line 22:
October 12, 2010, at 11:37 AM by 80.13.23.147 -
Added lines 3-7:
!! Sources
* http://www.skyhorse.org/web-server-administration/the-definite-guide-of-obscure-tweaks-to-install-and-maintain-cpanel-whm-version-10/monitoring-your-server

!! Logiciels
Changed lines 25-26 from:
to:
October 12, 2010, at 11:36 AM by 80.13.23.147 -
Changed line 12 from:
Ajouter la ligne suivante dans le fichier ~/.bash_profile de l'utilisateur :
to:
Ajouter la ligne suivante dans le fichier ''~/.bash_profile'' de l'utilisateur :
Changed lines 15-20 from:
to:
October 12, 2010, at 11:33 AM by 80.13.23.147 -
Changed lines 13-15 from:
@@echo "`whoami` login on `date` : `who`" | mail -s "[Login] `hostname` - `whoami` access from `who | awk '{print $5}'`" external-mail@domain.tld@@
to:
October 12, 2010, at 11:32 AM by 80.13.23.147 -
Changed line 3 from:
* [[Deb/logwatch]]
to:
* [[Deb/Logwatch]]
October 12, 2010, at 11:32 AM by 80.13.23.147 -
Changed lines 10-11 from:
!! Mails sur connexion utilisateur (root et autres si besoin)
to:
!! Envoi de mail sur connexion utilisateur (root et autres si besoin)
Deleted line 12:
October 12, 2010, at 11:31 AM by 80.13.23.147 -
Changed lines 3-9 from:
* [Deb/logwatch]
* [Deb/rkhunter]
* [Deb/chrootkit]
* [Deb/munin]
* [Deb/cron-apt]
* [Deb/snort]
to:
* [[Deb/logwatch]]
* [[Deb/rkhunter]]
* [[Deb/chrootkit]]
* [[Deb/munin]]
* [[Deb/cron-apt]]
* [[Deb/snort]]
October 12, 2010, at 11:31 AM by 80.13.23.147 -
Added lines 1-14:
! Monitorer son serveur

* [Deb/logwatch]
* [Deb/rkhunter]
* [Deb/chrootkit]
* [Deb/munin]
* [Deb/cron-apt]
* [Deb/snort]

!! Mails sur connexion utilisateur (root et autres si besoin)

Ajouter la ligne suivante dans le fichier ~/.bash_profile de l'utilisateur :

@@echo "`whoami` login on `date` : `who`" | mail -s "[Login] `hostname` - `whoami` access from `who | awk '{print $5}'`" external-mail@domain.tld@@
Edit - History - Print - Recent Changes - Search
Page last modified on October 12, 2010, at 02:58 PM