Outils pour utilisateurs

Outils du site


blog

Notes X11

Quel est mon gestionnaire de fenêtres - what is my window manager running

sudo apt-get install wmctrl
wmctrl -m

Ou plus simplement

printf 'Desktop: %s\nSession: %s\n' "$XDG_CURRENT_DESKTOP" "$GDMSESSION"

Lister toutes les fenêtres ouvertes sur le serveur X11

xwininfo -tree -root
 
#
wmctrl -l

Fermer un fenêtre en ligne de commande

wmctrl -l
wmctrl -ic 0x02e00085

ou

# replace WID with your window ID
kill $(wmctrl -lp | awk '/^WID/ {print $3}')

Notes install X11 sur RedHat7

yum downgrade glibc glibc-common
yum downgrade plymouth --setopt=protected_multilib=false
 
yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
 
yum install gcc make kernel-headers kernel-devel
 
rpm -qa | grep kernel
uname -r
 
rpm -e kernel-3.10.0-327.28.3.el7.x86_64
 
mount /dev/cdrom /mnt/
./VBoxLinuxAdditions.run
 
#yum install bash-completion
 
systemctl status vboxadd
systemctl status vboxadd-service
systemctl status vboxadd-x11
 
#yum groupinstall 'X Window System' 'GNOME'
yum groupinstall 'Server with GUI'  --skip-broken --setopt=protected_multilib=false
yum downgrade dbus-libs avahi-libs dbus avahi-autoipd
yum groupinstall 'Server with GUI'  --skip-broken --setopt=protected_multilib=false
 
 
yum install open-vm-tools open-vm-tools-desktop
  1. Install xauth: sudo yum install xorg-x11-xauth
  2. Edit the /etc/ssh/sshd_config file, and enter the X11Forwarding variable in Yes.
  3. Restart the sshd service: sudo service sshd restart

WayPipe

Similar to ssh -X

waypipe ssh user@theserver weston-terminal
 
waypipe -c lz4=9 ssh remote-server application-binary

How to make xterm black background by default

Add to ~/.Xdefaults :

xterm*background: black
xterm*foreground: white

or

alias xterm='xterm -bg black -fg white'
2025/03/24 15:06

Wrapper to use su as sudo - Emulating sudo's behaviour with su

Ma proposition

sudo.sh

#!/bin/bash
 
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details
 
ARGS_STRING=''
 
add_arg() {
        ARGS_STRING="${ARGS_STRING} $*"
}
 
echo "!!! WARNING: Using a fake sudo command !!!" >&2
 
while [ "${1-}" != "" ]; do
        case $1 in
        -s)
                shift
                add_arg "-s $1"
                ;;
        -u)
                shift
                add_arg "-p $1"
                ;;
        --)     # End of all options
                shift
                break
                ;;
        *)
                add_arg -c
                add_arg "'$*'"
                shift
                break
                ;;
        esac
        shift
done
 
# echo su "${ARGS_STRING}"
eval su "${ARGS_STRING}"

Autres exemples

Exemple 1
su_wrapper() {
    su -s /bin/bash -c "$(printf "%q " "$@")"
}

ou

su_wrapper() {
    local IFS=' '
    su -c "$*"
}

Source : https://stackoverflow.com/questions/24340664/emulating-sudos-behaviour-with-su

Exemple 2

sudo-su

#! /bin/sh
set -e
 
# A wrapper around su and sudo to implement a basic sudo-style interface with
# su and a basic su-style interface with sudo.
# 
# This can be useful when using tools such as pdebuild(1) that integrate
# privilege escalation only with sudo, or only with su: by having it run
# this program instead, you actually use su, or sudo instead seemlessly.
#
# Copyright (C) Tanguy Ortolo <tanguy+sudo-su@ortolo.eu> 2011
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details. 
 
 
usage()
{
    rc=$1
    echo "Usage: sudo-su COMMAND" >&2
    echo "       su-sudo -c \"COMMAND\"" >&2
    echo "sudo-su uses su to implement a basic sudo-style interface" >&2
    echo "su-sudo uses sudo to implement a basic su-style interface" >&2
    exit $rc
}
 
fake_sudo()
{
    TEMP="$(getopt -s sh -o +h --long help -n "$0" -- "$@")"
    if [ "$?" != 0 ]
    then
        usage $?
    fi
    eval set -- "$TEMP"
    while [ "$1" != "--" ]
    do
        case "$1"
        in
            -h|--help) usage 0 ; shift ;;
        esac
    done
    shift
    if [ "$#" -eq 0 ]
    then
        echo "sudo-su requires a command" >&2
        usage 1
    fi
 
    command=""
    for arg in "$@"
    do
        # To represent single quotes from single-quote mode:
        # leave single-quote mode, enter double-quote mode, write the single quote,
        # leave double-quote mode, enter single-quote mode.
        arg="$(echo "$arg" | sed -e "s/'/'\"'\"'/g")"
        if [ -z "$command" ]
        then
            command="'$arg'"
        else
            command="$command '$arg'"
        fi
    done
 
    exec su -c "$command"
}
 
fake_su()
{
    TEMP="$(getopt -s sh -o hc: --long help,command: -n "$0" -- "$@")"
    if [ "$?" != 0 ]
    then
        usage $?
    fi
    eval set -- "$TEMP"
    while [ "$1" != "--" ]
    do
        case "$1"
        in
            -h|--help) usage 0 ; shift ;;
            -c|--command) command="$2" ; shift 2 ;;
        esac
    done
    shift
    if [ "$#" -ne 0 ]
    then
        echo "We take only a -c option, no argument, sorry" >&2
        usage 1
    fi
    if [ -z "$command" ]
    then
        echo "su-sudo requires a command" >&2
        usage 1
    fi
 
    exec sudo sh -c "$command"
}
 
 
case "$(basename $0)"
in
    sudo*) fake_sudo "$@" ;;
    su*) fake_su "$@" ;;
esac

Sources :

Autres

Proper usage of su :

su -c "$0" "$ZOO_USER" "$@"
2025/03/24 15:06

Marquer le texte comme tâche.

windows - Tester un flux quand telnet n'est pas la

tnc 192.168.120.198 -Port 80

ou

Test-NetConnection 192.168.120.198 -Port 80
2025/03/24 15:06

Windows - Active Directory - Vérifier si un compte AD est verrouillé - locked

# export KRB5CCNAME=/var/lib/sss/db/ccache_ACME.LOCAL
# ldapsearch -H ldap://ldap.acme.local -Y GSSAPI -N -b "DC=ACME,DC=LOCAL" "(CN=COMPTE_AD_A_TESTER)" |grep -i lock
SASL/GSSAPI authentication started
SASL username: PLOP@ACME.LOCAL
SASL SSF: 256
SASL data security layer installed.
lockoutTime: 133195559287541069

Le compte est bien verrouillé

Si lockoutTime != 0 alors le compte est verrouillé.

Pour connaître depuis quand le compte est verrouillé sous windows :

C:\WINDOWS\system32>w32tm /ntte 133195559287541069
154161 12:38:48.7541069 - 30/01/2023 14:38:48

FIXME

2025/03/24 15:06

Serveur Samba SMB CIFS

Voir aussi

Notes

RHEL6 ne supporte pas le protocole SMB2 et +

Configuration

rlimit_max (1024) below minimum Windows limit (16384)

/etc/security/limits.d/30-samba.conf

root               -       nofile          16385

Défaut est max open files = 16385

Voir https://www.tecmint.com/install-samba-on-rhel-8-for-file-sharing-on-windows/

/etc/samba/smb.conf

[global]
        workgroup = WORKGROUP
        server string = Samba
        netbios name = SAMBA
        client ipc min protocol = SMB3
        client min protocol = SMB3
        server min protocol = SMB2
        disable netbios = Yes
        disable spoolss = Yes
        domain master = No      
        load printers = No
        local master = No
        log file = /var/log/samba/log.%m
 
        # Size in KB
        max log size = 200000
 
        name resolve order = host
        printcap name = /dev/null
        security = USER
        smb ports = 445
        idmap config * : backend = tdb
        passdb backend = tdbsam
        cups options = raw
        printing = bsd
        #log level = 3
        #restrict anonymous = 2
        #nt pipe support = no
        #interfaces = eth* lo
        #bind interfaces only = yes
        #fstype = Samba
        host msdfs = no
        server services = -s3fs, -rpc, -nbt, -wrepl, -ldap, -cldap, -kdc, -drepl, -winbindd, -ntp_signd, -kcc, -dnsupdate, -dns
 
[public]
        comment = Public
        read only = Yes
        path = /data/shared/public
 
[shared]
        #guest ok = Yes
        #browseable = No
        comment = Shared
        path = /mnt/shared
        read only = No
        #force user = jean
        valid users = jean
        write list = jean
 
#[IPC$]
#        hosts allow = 192.168.115.0/24 127.0.0.1
#        hosts deny = 0.0.0.0/0

Nul besoin de redémarrer le service, les modifications sont automatiquement prises en compte. Pour vérifier

testparm

Pour tester la connexion

smbclient -N -L 127.0.0.1
smbclient -N //127.0.0.1/shared
smbclient -U user%password //127.0.0.1/shared

Si besion modifier /etc/sysconfig/iptables ou firewalld

#iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 139 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT

Exemple :

/etc/samba/smb.conf

[partage]
   comment = Commentaires...
   path = /var/www
   force user = web
   #valid users = web
   browseable = yes
   writable = yes

Valider la configuration

testparm

Reload de la conf sans redémarrer

smbcontrol all reload-config

Redémarrer le service

systemctl restart smb
Faire un include d'un fichier de config.

C'est une fausse bonne idée car pas de reload automatique

/etc/samba/smb.conf

[global]
        path = /dev/null
 
[includes]
        available = No
        include = /etc/samba/smb.d/shared.conf

/etc/samba/smb.d/shared.conf

[shared]
        comment = Shared
        path = /mnt/shared
        read only = No

Authentification / comptes

Comment c'est configuré

testparm -sv /dev/null | grep auth
 
testparm -s '--parameter-name=server role'

Autoriser un utilisateur / définition du MDP

#pdbedit -a utilisateur
​smbpasswd -a utilisateur

Les utilisateurs à ajouter doivent exister au préalable dans /etc/passwd.

Cette option (et les suivantes) n'est disponible que lorsque smbpasswd est exécuté en tant que root

Supprimer un compte (retour arrière à précédent)

smbpasswd -x supervision

Désactiver un compte

smbpasswd -d supervision

Liste tous les comptes

pdbedit -L

Vérif l’existence de l'utilisateur pirate

pdbedit -u pirate

Dans un script shell

$ echo -n "P@ssw0rd" | base64
UEBzc3cwcmQ=

Duplication de l'entrée standard avec tee

# tee /dev/stdout
 
echo "UEBzc3cwcmQ=" | ( base64 -di ; echo )  | tee >(echo "$(</dev/stdin)") | smbpasswd -as user_samba

Désactiver l'impression

/etc/samba/smb.conf

[global]
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes

Source : http://mugurel.sumanariu.ro/linux/linux-how-to-disable-printing-in-samba/

Debug

/etc/samba/smb.conf

[global]
   log level = 3

Pas besoin de redémarrer le service, le reload est auto

Notes

smbstatus

Pb

Receiving SMB: Server stopped responding - Call returned zero bytes (EOF) opening remote
smb: \> get plop
Receiving SMB: Server stopped responding
Call returned zero bytes (EOF) opening remote file \plop
Solution

Le pb venait du fait que la partition /var était pleine.

Pb de connection depuis windows err NT_STATUS_WRONG_PASSWORD
Solution 1 (insecure)

/etc/samba/smb.conf

[global]
ntlm auth = yes
#client ntlmv2 auth = yes

Exemple de conf

Install sous RedHat / CentOS

cp -p /etc/samba/smb.conf /etc/samba/smb.conf.bak
egrep -v '^$|^#|^;' /etc/samba/smb.conf.bak > /etc/samba/smb.conf

/etc/samba/smb.conf

[global]
   workgroup = WORKGROUP
   dns proxy = no
   log file = /var/log/samba/log.%m
   max log size = 1000
   syslog = 0
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
   usershare allow guests = yes
 
[tmp]
   path = /tmp
   comment = TEMP
   browseable = yes
   read only = no
   create mask = 0660
   directory mask = 0770
   guest ok = yes
 
[partage]
   comment = Partage
   path = /data/
   force user = utilisateur1
   #public = yes
   valid users = @groupe1, jean
   write list = @groupe1, jean
   browseable = yes
   writable = yes
   read only = no

Autres

Pour conteneurs

/usr/sbin/smbd -F -S
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki