PROJET AUTOBLOG


Planet-Libre

source: Planet-Libre

⇐ retour index

Antistress : Pourquoi et comment faire tourner Windows 7 sous GNU/Linux avec Machines (alias Boxes), l'outil de virtualisation de GNOME

vendredi 21 février 2014 à 06:31

Logo de GNOME Machines, alias GNOME Boxes

Je vous ai récemment fait part de mon enthousiasme pour Machines, le logiciel de virtualisation dorénavant inclus dans votre environnement graphique favori (à noter qu'un processeur doté de la technologie de virtualisation VT-x est requis pour en profiter).

N'ayant pas voulu d'un dual boot GNU/Linux-Windows sur ma machine, il reste tout de même deux cas pour lesquels un environnement Windows m'est nécessaire : la mise à jour de mon nouveau boîtier GPS ; la réparation des systèmes de fichiers made in Windows endommagés.

En effet, dans le premier cas, la mise à jour du GPS se fait comme souvent au moyen d'un logiciel conçu « pour Windows et Mac ». Dans le deuxième cas, l'utilitaire CHKDSK.exe inclus dans Windows n'a pas d'équivalent aussi poussé à ma connaissance sous GNU/Linux.

Peut-être que Wine aurait suffit dans le premier cas me direz-vous, mais j'ai voulu éviter toute difficulté en lançant directement le système d'exploitation complet développé par la firme de Redmond, comme on dit (flasher un appareil reste une opération délicate). Et puis surtout je ne voyais pas comment lancer CHKDSK.exe sans Windows (si vous pouvez me contredire sur ces deux points ça me permettrait de me passer définitivement de devoir faire tourner Windows). Enfin, c'était l'occasion de faire joujou avec Machines...

Comment qu'on fait

Premier ingrédient : un système Windows... ou sa version d'essai

Dans un premier temps j'ai ressorti mon CD d'installation de Windows XP, puisque c'était le système d'exploitation que j'utilisais avant d'avoir la vision de Saint Richard. Quelle galère à installer (rien à voir avec l'installation d'une distribution GNU/Linux actuelle) ! D'autant que le Service Pack 2 est requis en sus pour après peu tous les logiciels actuels (dont Firefox), et que installer le Service Pack à partir d'Internet Explorer 6 est une vraie épreuve.

Au final je n'ai pas été récompensé de tout ce laborieux travail d'installation puisque je n'ai pas réussi à accéder à mes différents périphériques USB depuis Windows XP. Après en avoir recherché la cause en vain avec les développeurs concernés, je leur ai conseillé de laisser tomber mon cas particulier (d'autres ont plus de chance que moi) d'autant que Windows XP, c'est presque de l'histoire ancienne. Il faut dire que j'avais une solution alternative dans ma manche.

En effet il est possible de télécharger des versions d'essai de Windows 7 (avec Service Pack 1 qui plus est). Pour un usage occasionnel c'est parfait, d'autant qu'il faut reconnaître que cette version de Windows s'installe aussi facilement qu'une distribution GNU/Linux (pas besoin de rester devant son écran pour répondre à 50 questions tout au long de l'installation comme avec Windows XP) et qu'elle est déjà relativement à jour sitôt installée.

Deuxième ingrédient : les Windows guest tools

Pour une utilisation optimale, notamment l'exploitation complète de la résolution de votre moniteur mais aussi la prise en charge du copier/coller entre le système hôte et le système invité, je vous conseille toute de même d'installer les Windows guest tools (actuellement ils sont disponibles sous la forme du fichier spice-guest-tools-0.74.exe).

Troisième ingrédient : activer la redirection USB dans Machines

Enfin, lorsque vous branchez votre périphérique USB, rendez-vous dans les paramètres de Machines, rubrique Périphériques et activez « Rediriger les nouveaux périphériques USB » puis sélectionnez ceux du système hôte que vous souhaitez faire interagir avec le système invité (GPS relié en USB ou support de stockage USB dans mon cas).

Quatrième ingrédient : il n'y a plus qu'à

Pour la mise à jour de votre boîtier GPS, il ne reste plus alors qu'à installer le logiciel ad hoc.

Pour ce qui est de la réparation des systèmes de fichiers Windows corrompus, la commande « chkdsk /f e: » (où « e: » représente votre suport de stockage USB) permet précisément cela.

Gravatar de Antistress
Original post of Antistress.Votez pour ce billet sur Planet Libre.

Articles similaires

botchchikii : Quelques nouvelles du front

jeudi 20 février 2014 à 23:46

Voici un moment que je n'ai pas donné de nouvelles sur ce blog. Je suis actuellement en plein projet d'observation pour Peuple Loup et je découvre les beautés du massif du Vercors. Je vous invite à suivre mes péripéties et ma recherche de traces lupines ! Voici quelques liens pour cela :

Comme vous le voyez, j'ai succombé un peu aux sirènes obscures de sites Internet peu recommandables ^^ Mais il faut bien mettre en avant le projet et les actions de l'association si je veux continuer mon bonhomme de chemin.

Mon bureau

En ce qui concerne le Libre, je tourne toujours sous la distribution GNU/Linux Frugalware qui est maintenant en version 1.9. Nous devrions fêter les 10 ans d'existence de Fw cet été avec la version 2.0, nous aurons l'occasion d'en reparler je pense. Il est à noter que le site a été entièrement revu par Pacmiam et a retrouvé fière allure ! Ce dernier s'occupe également d'un front-end du gestionnaire de paquet, Pyfpm qui devrait permettre aux utilisateurs peu habitués à la ligne de commande de gérer cette distribution qui mériterait plus de lumières.

Je suis également toujours fidèle à i3wm, ce gestionnaire de fenêtres très léger n'a pour moi aucun défaut et a un potentiel énorme de personnalisation. Aucune raison de chercher ailleurs et il semblerait que sur le salon IRC de Frugalware, il fasse de plus en plus d'adeptes ;) Pour les autres applications, je n'ai pas trop modifié mes habitudes : Claws-mail est un incontournable, moins que Vim cependant ! Pour le gestionnaire de fichier, je tourne en ce moment avec Spacefm, fork de Pcmanfm. J'ai relancé Pidgin pour pouvoir être présent sur IRC et XMPP sans avoir à gérer 2 applications. Comme d'habitude, il fait les choses moyennement mais pour l'instant cela me convient. J'ai également changé d'émulateur de terminal : Urxvt est remplacé par Roxterm, que je trouve excellent.

En ce qui concerne Vim, j'ai trouvé un thème de couleur vraiment sympa récemment : Hybrid, surtout adapté à Gvim en fait mais cela me change de mes précédents thèmes. En parlant de thèmes, j'utilise le thème GTK Zen Nokto avec le thème d'icones Ice glass, je trouve qu'ils vont bien ensemble. Je vous mets un petit screenshot des familles pour vous montrer ce que cela donne. Ah oui, pour aller avec le thème, je lance dmenu avec le paramètre suivant dans la config d'i3 :

  bindsym $mod+j exec dmenu_run -sb "#246662"

Mon serveur

Maikan est toujours vaillant et opérationnel, même si le matériel commence a montrer quelques faiblesses. Je dois le rebooter un peu plus souvent mais le système est stable et les performances ne sont pas ridicules, loin de là. Vous pouvez visiter le blog de mon amie Drine, celui de Dirrevepeupleloup.info ou ce blog pour vous donner une idée.

Nous avons eu quelques soucis techniques avec Free le mois dernier : Ils ont eu l'amabilité de nous dégrouper sans nous prévenir et bien sur, de changer notre IP fixe, ce qui n'a pas trop aidé notre serveur web a distribué les pages :p Enfin, tout est réglé maintenant et nous avons gagné pas mal de débit (pas loin du double), ce qui est plutôt positif.

Voilà pour ces quelques nouvelles. J'avais un goût d'écrire en txt2tags sous Gvim et de refaire mouliner le nanoblogger sur Maikan. En passant, le développement de Nanoblogger semble être défintivement arrêté, ce qui va sûrement me faire réfléchir à changer, mais on en est pas là. Au plaisir, à la prochaine et prenez soin de vous !

Gravatar de botchchikii
Original post of botchchikii.Votez pour ce billet sur Planet Libre.

Quack1 : Ubuntu 14.04 — Le menu global pourra être intégré localement dans les fenêtres

jeudi 20 février 2014 à 22:18

 

Depuis Ubuntu 11.04, Unity intègre la barre de menus des applications dans la barre supérieure de l'écran.

Dans la version 14.04 qui sortira dans à peine deux mois, un paramètre du Control Center permettra de désormais afficher la barre de menu dans la barre supérieure de chaque fenêtre.

Un point plutôt intéressant pour les grandes tailles d'écrans ou les écrans à haute résolution, puisque cela limitera les mouvements de la souris à effectuer pour atteindre les menus! :)

Une présentation en vidéo par un développeur d'Unity :

Gravatar de Quack1
Original post of Quack1.Votez pour ce billet sur Planet Libre.

crowd42 : LBSA : script d’audit basique de la sécurité pour GNU/Linux

jeudi 20 février 2014 à 10:36

Un des grands avantages et des points forts des distributions GNU/Linux, c’est la sécurité out of the box qu’elles offrent. Mais comme on le sait tous, les cas sont rares où une installation ne subit aucune modification : nouveaux paquets installés, changements de droits et permissions, modification des fichiers de configuration… Et parfois, on peut se retrouver avec de sérieux problèmes !

Le script ci-dessous peut vous aider à détecter quelques-uns de ces problèmes. Il permet de faire un audit de votre installation et de vous alerter des possibles vulnérabilités d’authentification, dans les paramétrages du SSH, dans le système de fichier temporaire (/tmp, /var/tmp, /dev/shm) et dans la gestion des permissions.

Le script est très bien documenté et son auteur promet de le mettre à jour pour y ajouter de nouvelles fonctionnalités.

Un conseil, vérifier les recommandations de l’output du script, ne les exécutez pas sans savoir ce que vous faites ;)

#!/bin/sh

#------------------------------------------------------------------------------------------------------------------------------
# LBSA - Linux Basic Security Audit script
#------------------------------------------------------------------------------------------------------------------------------
# (c) Neale Rudd, Metawerx Pty Ltd, 2008-2009
# All rights reserved
# Download latest version from http://wiki.metawerx.net/wiki/LBSA
# Version 1.0.43
# Last updated 4/02/2009 8:01PM
#
#
#------------------------------------------------------------------------------------------------------------------------------
# GUIDE
#------------------------------------------------------------------------------------------------------------------------------
# This script runs a series of basic linux security checks.
# It is, and will always be, a work in progress.
# The script was originally designed for use on Ubuntu, but will most likely work with other distros.
#
# The checks are far from exhaustive, but can highlight some basic setup issues from default linux installs.
# Checks include a subset of setup policies which I use for hardening server configurations.  As such, not
# all checks may be suitable for your environment.  For example, I don't allow root to login over SSH.
# This may cause issues in your environment, or may be too restrictive for home use in some cases.
#
# If your own settings are more restrictive than these, or you have your own opinions on the settings, then
# modify this script to suit your own purposes.  The main idea is to have a script that can enforce your
# own policies, not to follow my policies line-by-line.
# 
# That said, this script should be suitable for most servers and home users "as-is", and for other admins
# it should give you some ideas for your own script, or at very least should make for a good read :-)
#
# Ideally, this script would be called by a wrapper script of your own, which implements similar checks
# more specific to your environment.  For example, if you run Apache, you may want to also check various
# folder permissions for Apache, then call this script as the final step of your own script.
# This script can be called regularly by cron, or other schedulers, to mail results to the appropriate
# administrator account for review.
#
# * Tests covered in the Bastille software are not covered here.
#
#
#------------------------------------------------------------------------------------------------------------------------------
# HOW TO USE
#------------------------------------------------------------------------------------------------------------------------------
# First, change parameters in the SETTINGS section to suit your environment, or call from your wrapper
# Script should be executed as root with sh.
# eg:
#   export LBSA_PERMITTED_LOGIN_ACCOUNTS="nrudd|sjackson"
#   sh sec_lbsa.sh
#
# No modifications are performed
# A series of checks are executed
# Running this script should produce no result except the phrase "System Checks Completed", at position 0
# of the output.
# If there is any other output, then one or more setup warnings have been issued
#
# This can be used in cron or another scheduler to send a mail using a command like the following:
#   export LBSA_PERMITTED_LOGIN_ACCOUNTS="nealerudd|sjackson";
#   LBSA_RESULTS=`sh sec_lbsa.sh`;
#   if [ "$LBSA_RESULTS" != "System Checks Completed" ]; then {your sendmail command here}; fi
#
#
#------------------------------------------------------------------------------------------------------------------------------
# SETTINGS
#------------------------------------------------------------------------------------------------------------------------------
# Settings are in if-blocks in case you want to call this script from a wrapper, to avoid modifying it
# This allows easier upgrades

# Permitted Login Accounts
#    Specify the list of permitted logins in quotes, separated by |
#    If there are none, just leave it blank.  root should not be listed here, as we don't want root logging in via SSH either.
#    Valid examples:
#    LBSA_PERMITTED_LOGIN_ACCOUNTS=""
#    LBSA_PERMITTED_LOGIN_ACCOUNTS="user1"
#    LBSA_PERMITTED_LOGIN_ACCOUNTS="user1|user2|user3"
if [ "$LBSA_PERMITTED_LOGIN_ACCOUNTS" = "" ]; then
    LBSA_PERMITTED_LOGIN_ACCOUNTS=""
fi

# If you aren't worried about allowing any/all SSH port forwarding, change this to yes
if [ "$LBSA_ALLOW_ALL_SSH_PORT_FORWARDING" = "" ]; then
    LBSA_ALLOW_ALL_SSH_PORT_FORWARDING=no
fi

# Set this to yes to provide additional SSH recommended settings
if [ "$LBSA_INCLUDE_EXTRA_SSH_RECOMMENDATIONS" = "" ]; then
    LBSA_INCLUDE_EXTRA_SSH_RECOMMENDATIONS=no
fi

#------------------------------------------------------------------------------------------------------------------------------
# LOGINS
#------------------------------------------------------------------------------------------------------------------------------

# ROOT_NOT_LOCKED
# Make sure root account is locked (no SSH login, console only)
passwd -S root | grep -v " L " | xargs -r -iLINE echo -e "Warning: root account is not locked and may allow login over SSH or other services.  When locked, root will only be able to log in at the console. [LINE]\\n"
# Fix: passwd -l root

# ROOT_PASS_TIMING
# Make sure root password is set to 0 min 99999 max 7 warning -1 inactivity
# This may occur with ROOT_PASS_EXPIRES
passwd -S root | grep -v "0 99999 7 -1" | xargs -r -iLINE echo -e "Warning: root account has non-standard min/max/wait/expiry times set.  If the root password expires, cron jobs and other services may stop working until the password is changed. [LINE]\\n"
# Fix: chage -m 0 -M 99999 -W 7 -I -1 root

# ROOT_PASS_EXPIRES
# Make sure root password is set to never expire
# This will normally occur with ROOT_PASS_TIMING
chage -l root | grep "Password expires" | grep -v never | xargs -r -iLINE echo -e "Warning: root password has an expiry date.  If the root password expires, cron jobs and other services may stop working until the password is changed. [LINE]\\n"
# Fix: chage -m 0 -M 99999 -W 7 -I -1 root

# ROOT_ACCT_EXPIRES
# Make sure root account is set to never expire
chage -l root | grep "Account expires" | grep -v never | xargs -r -iLINE echo -e "Warning: root account has an expiry date -- though Linux surely protects against it expiring automatically [recommend setting it to never expire]. [LINE]\\n"
# Fix: chage -E-1 root

# UNEXPECTED_USER_LOGINS_PRESENT
# Make sure the users that can log in, are ones we know about
# First, get user list, excluding any we already have stated should be able to log in
if [ "$LBSA_PERMITTED_LOGIN_ACCOUNTS" = "" ]; then
    USERLIST=`cat /etc/passwd | cut -f 1 -d ":"`
else
    USERLIST=`cat /etc/passwd | cut -f 1 -d ":" | grep -v -w -E "$LBSA_PERMITTED_LOGIN_ACCOUNTS"`
fi
# Find out which ones have valid passwords
LOGINLIST=""
for USERNAME in $USERLIST
do
    if [ "`passwd -S $USERNAME | grep \\" P \\"`" != "" ]; then
        if [ "$LOGINLIST" = "" ]; then
            LOGINLIST="$USERNAME"
        else
            LOGINLIST="$LOGINLIST $USERNAME"
        fi
    fi
done
# Report
if [ "$LOGINLIST" != "" ]; then
    echo "Warning: the following user(s) are currently granted login rights to this machine: [$LOGINLIST]."
    echo "If users in this list should be allowed to log in, please add their usernames to the LBSA_PERMITTED_LOGIN_ACCOUNTS setting in this script, or set the environment variable prior to calling this script."
    echo "If an account is only used to run services, or used in cron, the account should not be permitted login rights, so lock the account with [passwd -l ] to help prevent it being abused."
    echo "Note: after locking the account, the account will also be marked as expired, so use [chage -E-1 ] to set the account to non-expired/never-expire, otherwise services or cron tasks that rely on the user account being active will fail."
    echo ""
fi
# Fix: lock the specified accounts then set them non-expired, or specify the users that are listed are ok to log in by
# adding them to LBSA_PERMITTED_LOGIN_ACCOUNTS

#--------------------------------------------------------------------------------------------------------------
# General
#--------------------------------------------------------------------------------------------------------------

# Ensure /etc/hosts contains an entry for this server name
export LBSA_HOSTNAME=`hostname`
if [ "`cat /etc/hosts | grep \\"$LBSA_HOSTNAME\\"`" = "" ]; then echo "There is no entry for the server's name [`hostname`] in /etc/hosts.  This may cause unexpected performance problems for local connections.  Add the IP and name in /etc/hosts, eg: 192.168.0.1 `hostname`"; echo; fi

#--------------------------------------------------------------------------------------------------------------
# SSH Setup
#--------------------------------------------------------------------------------------------------------------

# Ensure SSHD config is set securely (we do use TcpForwarding, so allow TcpForwarding)
if [ "`cat /etc/ssh/sshd_config | grep -E ^Port`"                     = "Port 22"                    ]; then echo "SSHD Config: Port is set to default (22).  Recommend change to a non-standard port to make your SSH server more difficult to find/notice.  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^ListenAddress`"            = ""                           ]; then echo "SSHD Config: ListenAddress is set to default (all addresses).  SSH will listen on ALL available IP addresses.  Recommend change to a single IP to reduce the number of access points.  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^PermitRootLogin`"         != "PermitRootLogin no"         ]; then echo "SSHD Config: PermitRootLogin should be set to no (prefer log in as a non-root user, then sudo/su to root).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^PermitEmptyPasswords`"    != "PermitEmptyPasswords no"    ]; then echo "SSHD Config: PermitEmptyPasswords should be set to no (all users must use passwords/keys).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^UsePrivilegeSeparation`"  != "UsePrivilegeSeparation yes" ]; then echo "SSHD Config: UsePrivilegeSeparation should be set to yes (to chroot most of the SSH code, unless on older RHEL).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^Protocol`"                != "Protocol 2"                 ]; then echo "SSHD Config: Protocol should be set to 2 (unless older Protocol 1 is really needed).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^X11Forwarding`"           != "X11Forwarding no"           ]; then echo "SSHD Config: X11Forwarding should be set to no (unless needed).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^StrictModes`"             != "StrictModes yes"            ]; then echo "SSHD Config: StrictModes should be set to yes (to check file permissions of files such as ~/.ssh, ~/.ssh/authorized_keys etc).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^IgnoreRhosts`"            != "IgnoreRhosts yes"           ]; then echo "SSHD Config: IgnoreRhosts should be set to yes (this method of Authentication should be avoided).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^HostbasedAuthentication`" != "HostbasedAuthentication no" ]; then echo "SSHD Config: HostbasedAuthentication should be set to no (this method of Authentication should be avoided).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^RhostsRSAAuthentication`" != "RhostsRSAAuthentication no" ]; then echo "SSHD Config: RhostsRSAAuthentication should be set to no (this method of Authentication should be avoided).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^GatewayPorts`"            != ""                           ]; then echo "SSHD Config: GatewayPorts is configured.  These allow listening on non-localhost addresses on the server.  This is disabled by default, but has been added to the config file.  Recommend remove this setting unless needed.  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
if [ "`cat /etc/ssh/sshd_config | grep -E ^PermitTunnel`"            != ""                           ]; then echo "SSHD Config: PermitTunnel is configured.  This allows point-to-point device forwarding and Virtual Tunnel software such as VTun to be used.  This is disabled by default, but has been added to the config file.  Recommend remove this setting unless needed.  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi

# Commenting out Subsystem sftp is fairly pointless, SCP can still be used and most tools fall back to SCP automatically.  Additionally, it's possible to copy files using just SSH and redirection.
# if [ "`cat /etc/ssh/sshd_config | grep -E \\"^Subsystem sftp\\"`"      != ""                           ]; then echo "SSHD Config: Comment out Subsystem SFTP (unless needed).  While enabled, any user with SSH shell access can browse the filesystem and transfer files using SFTP/SCP.  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi

if [ "$LBSA_ALLOW_ALL_SSH_PORT_FORWARDING" != "yes" ]; then
    if [ "`cat /etc/ssh/sshd_config | grep -E ^AllowTcpForwarding`" != "" ]; then 
        if [ "`cat /etc/ssh/sshd_config | grep -E ^AllowTcpForwarding`" != "AllowTcpForwarding no" ]; then
            if [ "`cat /etc/ssh/sshd_config | grep -E ^PermitOpen`" = "" ]; then
                echo "SSHD Config: AllowTcpForwarding has been explicitly set to something other than no, but no PermitOpen setting has been specified.  This means any user that can connect to a shell or a forced-command based session that allows open port-forwarding, can port forward to any other accessible host on the network (authorized users can probe or launch attacks on remote servers via SSH port-forwarding and make it appear that connections are coming from this server).  Recommend disabling this feature by adding [AllowTcpForwarding no], or if port forwarding is required, providing a list of allowed host:ports entries with PermitOpen.  For example [PermitOpen sql.myhost.com:1433 mysql.myhost.com:3306].  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."
                echo "* Note: If this is ok for this machine, set LBSA_ALLOW_ALL_SSH_PORT_FORWARDING=yes in this script, or set the environment variable prior to calling this script."
                echo
            fi
        fi
    fi
    if [ "`cat /etc/ssh/sshd_config | grep -E ^AllowTcpForwarding`" = "" ]; then 
        if [ "`cat /etc/ssh/sshd_config | grep -E ^PermitOpen`" = "" ]; then
            echo "SSHD Config: AllowTcpForwarding is not specified, so is currently set to the default (yes), but no PermitOpen setting has been specified.  This means any user that can connect to a shell or a forced-command based session that allows open port-forwarding, can port forward to any other accessible host on the network (authorized users can probe or launch attacks on remote servers via SSH port-forwarding and make it appear that connections are coming from this server).  Recommend disabling this feature by adding [AllowTcpForwarding no], or if port forwarding is required, providing a list of allowed host:ports entries with PermitOpen.  For example [PermitOpen sql.myhost.com:1433 mysql.myhost.com:3306].  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."
            echo "* Note: If this is ok for this machine, set LBSA_ALLOW_ALL_SSH_PORT_FORWARDING=yes in this script, or set the environment variable prior to calling this script."
            echo
        fi
    fi
fi

# Additional recommendations (These are not critical, but helpful.  These are typically not specified so strictly by default
# so will almost definitely require the user to change some of the settings manually.  They are in an additional section
# because they are not as critical as the settings above.
if [ "$LBSA_INCLUDE_EXTRA_SSH_RECOMMENDATIONS" = "yes" ]; then

    # Specify DenyUsers/DenyGroups for extra protection against root login over SSH
    if [ "`cat /etc/ssh/sshd_config | grep -E ^DenyUsers | grep root`"  = "" ]; then echo "SSHD Config: (Extra Recommendation) DenyUsers is not configured, or is configured but has not listed the root user.  Recommend adding [DenyUsers root] as an extra protection against root login (allow only su/sudo to obtain root access).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
    if [ "`cat /etc/ssh/sshd_config | grep -E ^DenyGroups | grep root`" = "" ]; then echo "SSHD Config: (Extra Recommendation) DenyGroup is not configured, or is configured but has not listed the root group.  This means that if a user is added to the root group and are able to log in over SSH, then that login is effectively the same as a root login anyway.  Recommend adding [DenyUsers root] as an extra protection against root login (allow only su/sudo to obtain root access).  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi

    # Get rid of annoying RDNS lookups which can cause timeouts if RDNS fails
    if [ "`cat /etc/ssh/sshd_config | grep -E \\"^UseDNS no\\"`" = "" ]; then echo "SSHD Config: (Extra Recommendation) Set UseDNS no.  This will stop RDNS lookups during authentication.  Advantage 1: RDNS can be spoofed, which will place an incorrect entry in auth.log causing problems with automated log-based blocking of brute-force attack sources.  This change will eliminate the problem of RDNS spoofing.  Advantage 2: If RDNS fails, timeouts can occur during SSH login, preventing access to the server in worst cases.  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi

    # Reduce timeouts, max attempts and max number of concurrent logins
    LoginGraceTime=`cat /etc/ssh/sshd_config | grep ^LoginGraceTime | tr -s " " | cut -d " " -f 2`
    if [ "$LoginGraceTime" = "" ]; then LoginGraceTime=120; fi
    MaxAuthTries=`cat /etc/ssh/sshd_config | grep ^MaxAuthTries | tr -s " " | cut -d " " -f 2`
    if [ "$MaxAuthTries" = "" ]; then MaxAuthTries=6; fi
    MaxStartups=`cat /etc/ssh/sshd_config | grep ^MaxStartups | tr -s " " | cut -d " " -f 2`
    if [ "$MaxStartups" = "" ]; then MaxStartups=10; fi
    MaxConcurrent=`expr "$MaxStartups" "*" "$MaxAuthTries"`
    if [ "$LoginGraceTime" -gt 30 ]; then echo "SSHD Config: (Extra Recommendation) LoginGraceTime is set to [$LoginGraceTime].  This setting can be used to reduce the amount of time a user is allowed to spend logging in.  A malicious user can use a large time window to more easily launch DoS attacks or consume your resources.  Recommend reducing this to 30 seconds (or lower) with the setting [LoginGraceTime 30].  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
    if [ "$MaxAuthTries" -gt 4 ]; then echo "SSHD Config: (Extra Recommendation) MaxAuthTries is set to [$MaxAuthTries].  This allows the user $MaxAuthTries attempts to log in per connection.  The total number of concurrent login attempts your machine provides are ($MaxAuthTries MaxAuthTries) * ($MaxStartups MaxStartups) = $MaxConcurrent.  Note that only half of these will be logged.  Recommend reducing this to 4 (or lower) with the setting [MaxAuthTries 4].  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
    if [ "$MaxStartups" -gt 3 ]; then echo "SSHD Config: (Extra Recommendation) MaxStartups is set to [$MaxStartups].  This allows the user to connect with $MaxStartups connections at the same time, before authenticating.  The total number of concurrent login attempts your machine provides are ($MaxAuthTries MaxAuthTries) * ($MaxStartups MaxStartups) = $MaxConcurrent.  Note that only half of these will be logged.  Recommend reducing this to 3 (or lower) with the setting [MaxStartups 3].  (Remember to restart SSHD with /etc/init.d/ssh restart after making changes)."; echo; fi
fi

#------------------------------------------------------------------------------------------------------------------------------
# PERMISSIONS / OWNERS / GROUPS  -  LINUX TOP LEVEL FOLDER
#------------------------------------------------------------------------------------------------------------------------------

# FOLDER_PRIVS_755_root_LINUX_TOP_LEVEL
# Check privileges, owner, and group
FOLDERS="bin boot dev etc home initrd lib media mnt opt sbin srv sys usr var"
PERMS=drwxr-xr-x
OWNER=root
GROUP=root
for FOLDER in $FOLDERS
do
    ls / -l  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
    ls / -o  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
    ls / -lg | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
done

# FOLDER_PRIVS_1777_root_LINUX_TOP_LEVEL
# Check privileges, owner, and group
FOLDERS="tmp"
PERMS=drwxrwxrwt
OWNER=root
GROUP=root
for FOLDER in $FOLDERS
do
    ls / -l  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
    ls / -o  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
    ls / -lg | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
done

# FOLDER_PRIVS_555_root_LINUX_TOP_LEVEL
# Check privileges, owner, and group
FOLDERS="proc"
PERMS=dr-xr-xr-x
OWNER=root
GROUP=root
for FOLDER in $FOLDERS
do
    ls / -l  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
    ls / -o  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
    ls / -lg | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
done

# FOLDER_PRIVS_700_root_LINUX_TOP_LEVEL
# Check privileges, owner, and group
FOLDERS="root"
PERMS=drwx------
OWNER=root
GROUP=root
for FOLDER in $FOLDERS
do
    ls / -l  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
    ls / -o  | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
    ls / -lg | grep -v "\\->" | grep -w $FOLDER\\$ | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
done

#------------------------------------------------------------------------------------------------------------------------------
# PERMISSIONS / OWNERS / GROUPS  -  /ETC/SSH FOLDER
# Auto-fix all warnings in this area with: chmod 600 -R /etc/ssh; chown root:root -R /etc/ssh
#------------------------------------------------------------------------------------------------------------------------------

# 600 seems ok for the entire /etc/ssh folder.  I can connect to SSH OK, and make outgoing SSH connections OK as various users.
# This prevents non-root users from viewing or modifying SSH config details which could be used for attacks on other user
# accounts or potential privelege elevation.

PERMS=-rw-------
FILES="moduli sshd_config ssh_host_dsa_key ssh_host_rsa_key ssh_host_key blacklist.DSA-1024 blacklist.RSA-2048"
FOLDER=/etc/ssh
OWNER=root
GROUP=root
for FILE in $FILES
do
    if [ -e $FOLDER/$FILE ]; then
        ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"
        ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"
    fi
done

# Ubuntu defaults private keys to 600 all other files to 644
# CentOS defaults public keys to 644 all other files to 600
#PERMS=-rw-r--r--
PERMS=-rw-------
FILES="ssh_config ssh_host_dsa_key.pub ssh_host_rsa_key.pub ssh_host_key.pub"
FOLDER=/etc/ssh
OWNER=root
GROUP=root
for FILE in $FILES
do
    if [ -e $FOLDER/$FILE ]; then
        ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    fi
done

# Ubuntu defaults folder to 755
# CentOS defaults folder to 755
#PERMS=-rwxr-xr-x
PERMS=drw-------
FILES="ssh"
FOLDER=/etc
OWNER=root
GROUP=root
for FILE in $FILES
do
    if [ -e $FOLDER/$FILE ]; then
        ls $FOLDER -l  | grep $FILE | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER -o  | grep $FILE | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER -lg | grep $FILE | grep -v "\\->" | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    fi
done

#------------------------------------------------------------------------------------------------------------------------------
# PERMISSIONS / OWNERS / GROUPS  -  /ETC FOLDER SPECIAL FILES
#------------------------------------------------------------------------------------------------------------------------------

# -r--r-----  1 root     root        579 2007-02-09 01:52 sudoers

# -rw-------  1 root     root          0 2006-07-28 22:55 .pwd.lock
# -rw-------  1 root     root        938 2008-06-11 21:28 gshadow-
# -rw-------  1 root     root       1114 2008-06-11 21:28 group-
# -rw-------  1 root     root       2413 2008-09-03 14:39 shadow-
# -rw-------  1 root     root       3693 2008-09-03 14:39 passwd-

# -rw-r-----  1 root     daemon      144 2006-05-09 07:44 at.deny
# -rw-r-----  1 root     fuse        216 2007-09-19 10:01 fuse.conf
# -rw-r-----  1 root     shadow      950 2008-06-11 21:32 gshadow
# -rw-r-----  1 root     shadow     2346 2008-11-02 15:11 shadow

# -rwxr-xr-x  1 root     root        268 2006-04-06 03:40 rmt
# -rwxr-xr-x  1 root     root        306 2006-07-28 22:54 rc.local

# These are just the Ubuntu defaults
PERMS=-r--r-----
FOLDER=/etc
FILES="sudoers"
OWNER=root
GROUP=root
for FILE in $FILES
do
    ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
    ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
    ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
done

# These are just the Ubuntu defaults
PERMS=-rw-------
FOLDER=/etc
FILES=".pwd.lock gshadow- group- shadow- passwd-"
OWNER=root
GROUP=root
for FILE in $FILES
do
    ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
    ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
    ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
done

# These are just the Ubuntu defaults
PERMS=-rw-r-----
FOLDER=/etc
FILES="at.deny"
OWNER=root
GROUP=daemon
for FILE in $FILES
do
    if [ -e "$FOLDER/$FILE" ]; then
        ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP" | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    fi
done

# These are just the Ubuntu defaults
PERMS=-rw-r-----
FOLDER=/etc
FILES="fuse.conf"
OWNER=root
GROUP=fuse
for FILE in $FILES
do
    if [ -e "$FOLDER/$FILE" ]; then
        ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP" | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    fi
done

# These are just the Ubuntu defaults
PERMS=-rw-r-----
FOLDER=/etc
FILES="gshadow shadow"
OWNER=root
GROUP=shadow
for FILE in $FILES
do
    if [ -e "$FOLDER/$FILE" ]; then
        ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP" | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    fi
done

# These are just the Ubuntu defaults
PERMS=-rwxr-xr-x
FOLDER=/etc
FILES="rmt rc.local"
OWNER=root
GROUP=root
for FILE in $FILES
do
    ls $FOLDER/$FILE -l  | grep -v "\\->" | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
    ls $FOLDER/$FILE -o  | grep -v "\\->" | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
    ls $FOLDER/$FILE -lg | grep -v "\\->" | grep -v "$GROUP"  | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
done

#--------------------------------------------------------------------------------------------------------------
# CHECK FOR WORLD WRITABLE FOLDERS
#--------------------------------------------------------------------------------------------------------------

# Search for world writables in /etc or other folders
FOLDERS="/etc /bin /sbin /usr/bin"
for FOLDER in $FOLDERS
do
    # Find any files/folders in /etc which are world-writable
    # Future: also need to ensure files are owned by root.  If not, they may be able to be written to anyway.
    if [ "`find $FOLDER -type f -perm -002`" != "" ]; then
        echo "Warning: There are files or folders in $FOLDER which are world writable.  It is a security risk to have world-writables in this folder, as they may be executed by other scripts as root."
        echo "A complete list of these files follows:"
        find $FOLDER -type f -perm -002 | xargs -r ls -al
        echo ""
    fi
    if [ "`find $FOLDER -type d -perm -002`" != "" ]; then
        echo "Warning: There are folders in $FOLDER which are world writable.  It is a security risk to have world-writables in this folder, as they may be executed by other scripts as root."
        echo "A complete list of these folders follows:"
        find $FOLDER -type d -perm -002
        echo ""
    fi
done

#--------------------------------------------------------------------------------------------------------------
# CHECK FOR INSECURE TMP AND SHM FOLDERS /tmp, /usr/tmp, /var/tmp, /dev/shm
#--------------------------------------------------------------------------------------------------------------

# TODO: this doesn't check /usr/tmp or /var/tmp yet

# /tmp

# First ensure that /tmp is a separate partition in mtab, otherwise the following tests are useless
if [ "`cat /etc/mtab | grep /tmp`" = "" ]; then
    echo "Warning: /tmp is not a separate partition, so cannot be marked nodev/nosuid/noexec";
else

    # Ensure noexec
    # Note: Even though most admins recommend /tmp is noexec, the aptitude (apt-get) tool in do-release-upgrade mode
    # require exec permissions in /tmp and will stop with an error before installing the upgrade because /tmp has no exec permissions.
    # Workaround: Either edit /etc/apt/apt.conf and change the TempDir for apt to something else (such as /var/cache/apt/tmp), or before using the do-release-upgrade command, use this command to temporarily assign exec rights on /tmp: [mount -oremount,exec /tmp]
    if [ "`cat /etc/mtab | grep /tmp | grep noexec`" = "" ]; then
        echo "Warning: /tmp has EXECUTE permissions.  Recommend adding noexec attribute to mount options for /tmp, in /etc/fstab."
        echo "This change will help in preventing malicious users from installing and executing binary files from the folder."
        echo "To test, run these commands.  The output should say Permission denied if your system is already protected: cp /bin/ls /tmp; /tmp/ls; rm /tmp/ls;"
        echo "Tip: after adding the attribute, you can remount the partition with [mount -oremount /tmp] to avoid having to reboot."
        echo "Note: Even though most admins recommend /tmp is noexec, Ubuntu release upgrades require exec permissions in /tmp for some reason and will stop with an error before installing the upgrade because /tmp has no exec permissions."
        echo "Workaround: Either edit /etc/apt/apt.conf and change the TempDir for apt to something else (such as /var/cache/apt/tmp), or before using the do-release-upgrade command, use this command to temporarily assign exec rights on /tmp: [mount -oremount,exec /tmp]"
        echo ""
    fi

    # Ensure nosuid
    if [ "`cat /etc/mtab | grep /tmp | grep nosuid`" = "" ]; then
        echo "Warning: /tmp has SUID permissions.  Recommend adding nosuid attribute to mount options for /tmp, in /etc/fstab."
        echo "This change will help in preventing malicious users from setting SUID on files on this folder.  SUID files will run as root if they are owned by root."
        echo "Tip: after adding the attribute, you can remount the partition with [mount -oremount /tmp] to avoid having to reboot."
        echo ""
    fi

    # Ensure nodev
    if [ "`cat /etc/mtab | grep /tmp | grep nodev`" = "" ]; then
        echo "Warning: /tmp has DEVICE permissions.  Recommend adding nodev attribute to mount options for /tmp, in /etc/fstab."
        echo "This change will help in preventing malicious users from creating device files in the folder.  Device files should be creatable in temporary folders."
        echo "Tip: after adding the attribute, you can remount the partition with [mount -oremount /tmp] to avoid having to reboot."
        echo ""
    fi
fi

# /dev/shm

if [ "`cat /etc/mtab | grep /dev/shm`" != "" ]; then

    # Ensure noexec
    if [ "`cat /etc/mtab | grep /dev/shm | grep noexec`" = "" ]; then
        echo "Warning: /dev/shm has EXECUTE permissions.  Recommend adding noexec attribute to mount options for /dev/shm, in /etc/fstab."
        echo "This change will help in preventing malicious users from installing and executing malicious files from the folder."
        echo "To test, run these commands.  The output should say Permission denied if your system is already protected: cp /bin/ls /dev/shm; /dev/shm/ls; rm /dev/shm/ls;"
        if [ "`cat /etc/fstab | grep /dev/shm`" = "" ]; then
            echo "Note: you do not currently have /dev/shm listed in /etc/fstab, so it is being mounted with default options by Linux."
            echo "To fix, add this line to /etc/fstab, then remount it with [mount -oremount /dev/shm] to avoid having to reboot."
            echo "none /dev/shm tmpfs defaults,noexec,nosuid,nodev 0 0"
            echo ""
        else
            echo "Tip: after adding the attribute, you can remount the partition with [mount -oremount /dev/shm] to avoid having to reboot."
        fi
        echo ""
    fi

    # Ensure nosuid
    if [ "`cat /etc/mtab | grep /dev/shm | grep nosuid`" = "" ]; then
        echo "Warning: /dev/shm has SUID permissions.  Recommend adding nosuid attribute to mount options for /dev/shm, in /etc/fstab."
        echo "This change will help in preventing malicious users from setting SUID on files on this folder.  SUID files will run as root if they are owned by root."
        if [ "`cat /etc/fstab | grep /dev/shm`" = "" ]; then
            echo "Note: you do not currently have /dev/shm listed in /etc/fstab, so it is being mounted with default options by Linux."
            echo "To fix, add this line to /etc/fstab, then remount it with [mount -oremount /dev/shm] to avoid having to reboot."
            echo "none /dev/shm tmpfs defaults,noexec,nosuid,nodev 0 0"
            echo ""
        else
            echo "Tip: after adding the attribute, you can remount the partition with [mount -oremount /dev/shm] to avoid having to reboot."
        fi
        echo ""
    fi

    # Ensure nodev
    if [ "`cat /etc/mtab | grep /dev/shm | grep nodev`" = "" ]; then
        echo "Warning: /dev/shm has DEVICE permissions.  Recommend adding nodev attribute to mount options for /dev/shm, in /etc/fstab."
        echo "This change will help in preventing malicious users from creating device files in the folder.  Device files should be creatable in temporary folders."
        if [ "`cat /etc/fstab | grep /dev/shm`" = "" ]; then
            echo "Note: you do not currently have /dev/shm listed in /etc/fstab, so it is being mounted with default options by Linux."
            echo "To fix, add this line to /etc/fstab, then remount it with [mount -oremount /dev/shm] to avoid having to reboot."
            echo "none /dev/shm tmpfs defaults,noexec,nosuid,nodev 0 0"
            echo ""
        else
            echo "Tip: after adding the attribute, you can remount the partition with [mount -oremount /dev/shm] to avoid having to reboot."
        fi
        echo ""
    fi
fi

#--------------------------------------------------------------------------------------------------------------
# CHECK HEARTBEAT CONFIG (if present)
#--------------------------------------------------------------------------------------------------------------

if [ -e /etc/ha.d ]; then

    # Default is 755, but no reason for non-root users to have access to these details
    # FOLDER_PRIVS_600_etc_HA
    # Check privileges, owner, and group
    FOLDER="/etc"
    FILES="ha.d"
    PERMS=drw-------
    OWNER=root
    GROUP=root
    for FILE in $FILES
    do
        ls $FOLDER -l  | grep -v "\\->" | grep $FILE | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER -o  | grep -v "\\->" | grep $FILE | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER -lg | grep -v "\\->" | grep $FILE | grep -v "$GROUP" | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    done

    # Default is 600, but make sure it doesn't change
    # If details are known by user accounts, they can potentially send malicious heartbeat messages over UDP and cause havoc
    # FILE_PRIVS_600_etc_HA
    # Check privileges, owner, and group
    FOLDER="/etc/ha.d"
    FILES="authkeys"
    PERMS=-rw-------
    OWNER=root
    GROUP=root
    for FILE in $FILES
    do
        ls $FOLDER -l  | grep -v "\\->" | grep $FILE | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER -o  | grep -v "\\->" | grep $FILE | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER -lg | grep -v "\\->" | grep $FILE | grep -v "$GROUP" | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    done
fi

#--------------------------------------------------------------------------------------------------------------
# CHECK DRBD CONFIG (if present)
#--------------------------------------------------------------------------------------------------------------

if [ -e /etc/drbd.conf ]; then

    # Default is 755, but if users have access to this file they can find out the shared-secret encryption key
    # FOLDER_PRIVS_600_etc_DRBD
    # Check privileges, owner, and group
    FOLDER="/etc"
    FILES="drbd.conf"
    PERMS=-rw-------
    OWNER=root
    GROUP=root
    for FILE in $FILES
    do
        ls $FOLDER -l  | grep -v "\\->" | grep $FILE | grep -v "^$PERMS" | xargs -r -iLINE echo -e "Permission recommendation $PERMS does not match current setting LINE\\n"
        ls $FOLDER -o  | grep -v "\\->" | grep $FILE | grep -v "$OWNER"  | xargs -r -iLINE echo -e "Owner recommendation $OWNER does not match current setting LINE\\n"     
        ls $FOLDER -lg | grep -v "\\->" | grep $FILE | grep -v "$GROUP" | xargs -r -iLINE echo -e "Group recommendation $GROUP does not match current setting LINE\\n"     
    done

    # Check that drbd.conf contains shared-secret keys, otherwise there is no protection against malicious external DRBD packets
    if [ "`grep shared-secret /etc/drbd.conf`" = "" ]; then
        echo "Warning: No shared-secret configured in /etc/drbd.conf.  There is no protection against malicious external DRBD packets which may cause data corruption on your DRBD disks.  Ensure that every disk is configured with a shared-secret attribute."; echo;
    fi

fi

#--------------------------------------------------------------------------------------------------------------
# DONE
#--------------------------------------------------------------------------------------------------------------

echo System Checks Completed

#--------------------------------------------------------------------------------------------------------------
# Notes
#--------------------------------------------------------------------------------------------------------------

# Show account expiry/change info for all logins
#  cat /etc/passwd | cut -f 1 -d ":" | xargs -r -I USERNAME chage -l USERNAME
# Future: check sysctl network settings
# Future: implement functions instead of all these loops
# Future: use stat -c %a  or stat -c %A  and better if checks instead of all the text processing, this is useful too: find -printf "%m\\t%P\\n"
# Future: since changing to sh, echo -e causes the text "-e" to be printed if using sh instead of bash.  Fix by moving reporter-lines into functions.

source

Cet article LBSA : script d’audit basique de la sécurité pour GNU/Linux est apparu en premier sur crowd42.

Related posts:

  1. Sécurité : utiliser Lynis pour effectuer un audit de votre système GNU/Linux
  2. Theme script : un script bash pour personnaliser votre bureau ubuntu [Gnome Shell]
  3. Archey, un script pour rendre votre terminal plus sexy

Gravatar de crowd42
Original post of crowd42.Votez pour ce billet sur Planet Libre.

La vache libre : CutePad – Un éditeur de texte original pour GNU/Linux et MS Windows

jeudi 20 février 2014 à 07:30

Les éditeurs de texte sont nombreux sous GNU/Linux et il y en a vraiment pour tous les goûts, que ce soit en termes d’interface ou de fonctionnalités. CutePad est justement un éditeur de texte un peu particulier, qui propose une interface graphique originale et quelques fonctions intéressantes. Comme vous pouvez le voir sur la capture ci-dessus, la section « Font » permet d’insérer du texte avec les options de mise en forme classiques : gras, italique, texte souligné, texte barré etc … La première originalité que nous pourrons souligner, c’est qu’il nous sera possible de choisir très rapidement la taille des caractères à l’aide d’un curseur dédié à cet effet et la couleur du texte à l’aide des carrés colorés situés à droite.

Sur cette capture vous pouvez voir la section « Format », qui va nous permettre de gérer la mise en page du texte grâce aux options d’alignement, d’indentation et d’espacement.

Ici nous pouvons voir la section « Sort », grâce à laquelle il nous sera possible d’utiliser des liste à puces ou numérotées.

Cette capture met en avant l’outil de recherche, à partir duquel vous serez en mesure de rechercher des mots ou des expressions dans le fichier, ce qui peut s’avérer très pratique pour les gros documents.

Cette capture nous montre un menu très intéressant de CutePad, qui va vous permettre d’insérer des éléments tels que des images, un tableau, des liens, un calendrier ou encore l’heure.

Et enfin sur celle-ci vous pouvez voir les quelques paramètres de base de l’application.

C’est un peu étrange car j’ai fait un billet qui parle d’un éditeur de texte, mais dans les faits ces captures d’écran et le sentiment que j’ai eu en l’essayant, m’ont fait penser à tout autre chose. J’ai eu l’impression d’avoir entre les mains un éditeur de texte insuffisant, si on le compare à des alternatives telles que Gedit. Cela dit cette insuffisance est comblée par des fonctions de mise en page que l’on retrouve habituellement dans des suites bureautiques.

Je pense pouvoir dire sans trop me tromper qu’il ne conviendra sans doute pas à ceux qui veulent un éditeur de texte puissant, dans le but de coder un peu de temps en temps. Si en revanche vous cherchez à faire de la rédaction pure et dure sans obligatoirement devoir dégainer la suite bureautique, il y a des chances qu’il vous plaise.

Alors si ça vous tente et que vous voulez en savoir plus sur CutePad, vous pouvez faire un tour sur la page officielle du projet.

Si vous le souhaitez, vous pouvez également vous procurer les sources ou les binaires pour votre distribution GNU/Linux et MS Windows, sur la page de téléchargement du projet. Une version est également disponible pour Arch Linux et Manjaro via AUR.

Amusez-vous bien.

source

Gravatar de La vache libre
Original post of La vache libre.Votez pour ce billet sur Planet Libre.