Outils pour utilisateurs

Outils du site


blog

Monter un serveur SFTP (SSH) avec ProFTPd

Voir : http://linuxfr.org/news/se-passer-de-dropbox-en-montant-son-coffre-fort-numerique-a-la-maison

Voir aussi :

Ne pas confondre FTPS avec SFTP !

apt-get install proftpd-basic

/etc/proftpd/proftpd.conf

#<Limit LOGIN>
#    Allow from 127.0.0.1 192.168.1.0/8
#    Allow from 78.233.103.193
#    DenyAll
#</Limit>
 
#######
##
## SFTP Config
SFTPEngine      On
Port <PORT>
SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/ssh/ssh_host_dsa_key
SFTPClientMatch "WS_FTP" channelWindowSize 1GB
# enable for sftp debugging:
TraceLog /var/log/proftpd/sftp-trace.log
#Trace scp:20 sftp:20 ssh2:20
Trace scp:7 sftp:7 ssh2:7
## End SFTP Config
##
SFTPLog            /var/log/proftpd/sftp.log
TransferLog        /var/log/proftpd/sftp-xferlog
 
SFTPAuthMethods    publickey password
#SFTPAuthMethods    publickey
AuthUserFile       /etc/proftpd/sftp.passwd
#SFTPAuthorizedUserKeys file:/etc/proftpd/authorized_keys/%u
SFTPAuthorizedUserKeys file:/etc/proftpd/sftp.passwd.keys/%u
 
# SFTP specific configuration
#DefaultRoot        ~
DefaultRoot        /partage
 
 
# Enable compression
SFTPCompression delayed
 
######

/etc/proftpd/sftp.passwd

<USER>:<$1$PASSWORD.>:1005:1008::/partage:/usr/bin/rssh

/etc/rssh.conf

user=<USER>:007:000110:"/partage"

Déposez les clef SSH publiques (à convertir) /etc/proftpd/sftp.passwd.keys/ Now fill the file with the SSH public keys you want. You need to convert it in RFC4716 style before:

ssh-keygen -e -f id_rsa.pub > /etc/proftpd/sftp.passwd.keys/virtual2
mkdir /etc/proftpd/authorized_keys
ssh-keygen -e -f id_rsa.pub > /etc/proftpd/authorized_keys/jean
chmod 600 /etc/proftpd/authorized_keys
chmod 600 /etc/proftpd/authorized_keys/*
service proftpd restart

Installation sur Debian ou Ubuntu

Avant toute chose vérifier que votre système d'exploitation soit à jour

sudo -s
apt-get update 
apt-get upgrade 
apt-get dist-upgrade
 
apt-get install proftpd-basic rssh
 
mkdir -p /partage/jean
mkdir -p /partage/public
addgroup sftp 
chgrp sftp /partage -R
chmod 750 /partage/*
chmod 1777 /partage/public
<Limit LOGIN>                                                        
    Allow from 78.234.113.74 127.0.0.1 192.168.2.0/8                
    DenyAll                                                          
</Limit>                                                             

/etc/proftpd/proftpd.conf

#######
  ## SFTP Config
  SFTPEngine      On
  Port 7010
  SFTPHostKey /etc/ssh/ssh_host_rsa_key
  SFTPHostKey /etc/ssh/ssh_host_dsa_key
  SFTPClientMatch "WS_FTP" channelWindowSize 1GB
  # enable for sftp debugging:
  TraceLog /var/log/proftpd/sftp-trace.log
  #Trace scp:20 sftp:20 ssh2:20
  Trace scp:7 sftp:7 ssh2:7
  
  SFTPLog            /var/log/proftpd/sftp.log
  TransferLog        /var/log/proftpd/sftp-xferlog
  SFTPAuthMethods    publickey password
  AuthUserFile       /etc/proftpd/sftp.passwd
  SFTPAuthorizedUserKeys file:/etc/proftpd/sftp.passwd.keys/%u
  
  # SFTP specific configuration
  DefaultRoot        ~   
 
  # Enable compression
  SFTPCompression delayed
  ######

Changer :

Port
Umask                           007  007
#TransferLog
$ getent group sftp |cut -d':' -f3
1008
$ mkpasswd --hash=md5 $PASS
$1$L0PQHYcl$fUkBeMISuAg.miC0qJONP.
cat >>/etc/proftpd/sftp.passwd <EOF
jean:$1$L0PQHYcl$fUkBeMISuAg.miC0qJONP.:1005:1008::/partage:/usr/bin/rssh
EOF

/etc/rssh.conf

logfacility = LOG_USER
umask = 066
 
 
# if your chroot_path contains spaces, it must be quoted... 
# In the following examples, the chroot_path is "/usr/local/my chroot" 
#user=rudy:011:000010:"/usr/local/my chroot"  # scp with chroot 
#user=rudy:011:000100:"/usr/local/my chroot"  # sftp with chroot 
#user=rudy:011:000110:"/usr/local/my chroot"  # both with chroot 
user=jean:007:000110:"/partage"  # both with chroot
 
chrootpath = "/partage"

/etc/passwd

jean:x:1006:1007:,,,:/home/jean:/usr/sbin/nologin

Connexion sans mot de passe

ssh-keygen -e -f ~/.ssh/id_dsa.pub
---- BEGIN SSH2 PUBLIC KEY ---- 
Comment: "1024-bit DSA, converted by jibe@bureau1 from OpenSSH" 
AAAAB3NzaC1kc3MAAACBAJA018SvcOTMOWCnPf+nF8QvPd31ei0spdxTgzualoieKkInx7 
glj+4zoxfUbweL4XmouUpzx0qDWE5EvFp+tNCJpKBrksq2tTPfkRqNl96gpXzY3SzWqslh 
ZQSyuSYaTK09r+IGGK1TRQCSzOXysCPpUGMxUDL3lhG8G7uHmFp3AAAAFQD7+zbnWBW49f 
chkTgTGUXn/ySKXQAAAIBzG//psWQ1KXHDbVNkJIyYfACH+fBiHKO4zhIYSYDbTU8sQBQ9 
bAnzDsUFAlLLmeEZOuux4zeGEPvjqGn+pCbpSRfY8FD3ItdGgipf0SiVpRL1b3uP1GrMpe 
IoQja1nnf7rsQBasWWsw2g3kvYz8OZnYCckVZDzbd0um+gRVRndQAAAIBfsJjGVF90lPWo 
sv1Mqsrn/itJGX67lHyWMLLVJ5/9SgmB4fY66OJXX8Ht7eH98kT5DXQEZ8Rms5WA4/u7SL 
Qbf/t1G096eMuA3WjrxBUOmQnVfGbAKVSQnt8MChikaxu4CChzjk08IfidTPoEdDfSqmZ2 
cE9X54zlPNJ8j+wqCA== 
---- END SSH2 PUBLIC KEY ---- 

Copier la clef publique sur le serveur SFTP :

  • /etc/proftpd/sftp.passwd.keys/jean
2025/03/24 15:06

Monter son serveur mail sous Debian

Configuration du serveur SMTP Postfix

serv1

/etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
 
 
# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
 
#smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_banner = Every illegal access will be referred to the appropriate authorities and the CERT.
biff = no
 
# appending .domain is the MUA's job.
append_dot_mydomain = no
 
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
 
readme_directory = no
 
# TLS parameters
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
 
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
 
myhostname = serv1.acme.fr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = acme.fr, serv1.acme.fr, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.16.0.0/12
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
 
home_mailbox = Maildir/
mailbox_command = procmail -a "$EXTENSION"
 
#smtpd_sasl_local_domain =
#smtpd_sasl_auth_enable = yes
#broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
 
smtpd_sasl_type = dovecot
 
smtpd_sasl_security_options = noanonymous
 
smtpd_tls_auth_only = yes
 
# Can be an absolute path, or relative to $queue_directory
# Debian/Ubuntu users: Postfix is setup by default to run chrooted, so it is best to leave it as-is below
smtpd_sasl_path = private/auth
 
# On Debian Wheezy path must be relative and queue_directory defined
#queue_directory = /var/spool/postfix
 
# and the common settings to enable SASL:
smtpd_sasl_auth_enable = yes
# With Postfix version before 2.10, use smtpd_recipient_restrictions
#smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
 
# virtual_alias_maps = hash:/etc/postfix/virtual
 
# inbound
smtpd_tls_security_level = may
smtpd_tls_protocols=!SSLv2,!SSLv3
smtpd_tls_mandatory_protocols=!SSLv2,!SSLv3
# outbound
smtp_tls_security_level = may
smtp_tls_protocols=!SSLv2,!SSLv3
smtp_tls_mandatory_protocols=!SSLv2,!SSLv3

Koala /etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
 
 
# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
 
#smtpd_banner = $myhostname ESMTP $mail_name (GNU)
smtpd_banner = Every illegal access will be referred to the appropriate authorities and the CERT.
biff = yes
 
# appending .domain is the MUA's job.
append_dot_mydomain = no
 
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
 
readme_directory = no
 
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
 
 
myhostname = smtp.acme.fr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = acme.fr, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.2.0/24 172.16.0.0/12
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
message_size_limit = 10485760
recipient_delimiter = +
inet_interfaces = all
 
virtual_alias_maps = hash:/etc/postfix/virtual
relay_domains = acme.fr
 
home_mailbox = Maildir/
notify_classes = resource, software, protocol
 
defer_transports = smtp
delay_warning_time = 5m
#maximal_queue_lifetime = 5d
 
debug_peer_level = 7
#default_transport = smtp:smtp.acme.fr
defer_transports =
disable_dns_lookups = no

/etc/mailname

acme.fr

/etc/aliases

# See man 5 aliases for format
dev-null:       /dev/null
postmaster:     root
abuse:          root
jean:           jibe
root:           jibe

# https://arno0x0x.wordpress.com/2016/02/07/postfix-lancer-un-script-sur-reception-dun-e-mail/
bot: "|/path/to/script/mailBot.php"

Puis

/etc/postfix/virtual

emailadresse   comptelocal
postmap /etc/postfix/virtual

Puis

vi /etc/aliases
newaliases
mkdir /etc/skel/Maildir/
mkdir /etc/skel/Maildir/cur
mkdir /etc/skel/Maildir/new
mkdir /etc/skel/Maildir/tmp
touch /etc/skel/Maildir/Trash
touch /etc/skel/Maildir/Drafts
touch /etc/skel/Maildir/Sent

/etc/skel/.procmailrc

VERBOSE=Yes
SHELL=/bin/bash
PATH=$HOME/bin:/usr/bin:/bin:/usr/local/bin:.
MAILDIR=$HOME/Maildir/ # You d better make sure it exists
DEFAULT=$MAILDIR/$USERNAME
LOGFILE=$MAILDIR/.procmail.log
LOCKFILE=$HOME/.lockmail
LOGNAME=$USERNAME

Configuration Dovecot

Pour tester la conf

dovecot -F

/etc/dovecot/dovecot.conf

#mail_location = maildir:~/Maildir
mail_driver = maildir
mail_path = ~/Maildir

/etc/dovecot/conf.d/10-auth.conf

#disable_plaintext_auth = yes   # Obsolete

/etc/dovecot/conf.d/15-mailboxes.conf

  mailbox Drafts {
    auto = subscribe          # <-- ADD THIS
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Trash {
    # Fix invisible Trash
    auto = subscribe         # <-- ADD THIS
    special_use = \Trash
  }

https://www.linode.com/docs/security/security-patches/disabling-sslv3-for-poodle

/etc/dovecot/conf.d/10-ssl.conf

ssl = required
ssl_protocols = !SSLv2 !SSLv3

Debug

doveadm -Dv force-resync -u jibe INBOX

/etc/letsencrypt/cli.ini

# Source : https://gist.github.com/mrothNET/cb6f313e9cbe896f3e0fdec80ad2f3fa
 
# Manage Firewall
#pre-hook = ufw allow http
#post-hook = ufw deny http
 
# Restart Postfix & Dovecot
renew-hook = systemctl restart dovecot.service postfix.service

Dovecot Exploit

Nettoyage cache / log

find ~/Maildir/ -type f \( -iname dovecot.index.cache -o -iname dovecot.index.log \) -delete
Pb

Pb suite à mis-à-jour Wheezy⇒Stretch

/var/log/mail.log

Jan 19 18:42:10 sever1 dovecot[394]: imap-login: Fatal: Invalid ssl_protocols setting: Unknown protocol 'SSLv2'

Solution de contournement provisoir

/etc/dovecot/conf.d/10-ssl.conf

#ssl_protocols = !SSLv2 !SSLv3
ssl_protocols = !SSLv3
systemctl restart dovecot
Postfix authentification avec Dovecot

Vérification compatibilité authentification Docecot

# postconf -a
cyrus
dovecot

/etc/dovecot/conf.d/10-master.conf

# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
      mode = 0660
      user = postfix
      group = postfix
}
/etc/init.d/dovecot restart
$ ls -l /var/spool/postfix/private/auth
srw-rw---- 1 postfix postfix 0 mai   20 12:48 /var/spool/postfix/private/auth

/etc/postfix/main.cf

smtpd_sasl_security_options = noanonymous
smtpd_tls_auth_only = yes
 
smtpd_sasl_type = dovecot
 
# Can be an absolute path, or relative to $queue_directory
# Debian/Ubuntu users: Postfix is setup by default to run chrooted, so it is best to leave it as-is below
smtpd_sasl_path = private/auth
 
# On Debian Wheezy path must be relative and queue_directory defined
#queue_directory = /var/spool/postfix
 
# and the common settings to enable SASL:
smtpd_sasl_auth_enable = yes

Configuration DNS

  • champ MX
  • SRV (TXT)

Vérification

Vérification sécurité

Avant toute chose nous devons être certain que notre serveur SMTP n'est pas un relais ouvert.

telnet smtp.acme.fr 25
EHLO localhost

Vous devez voir la ligne suivante :

250-STARTTLS
$ echo -ne "\0nom\0MOTDEPASS" |openssl enc -base64
AG5vbQBNT1RERVBBU1M=
openssl s_client -tls1 -starttls smtp -crlf -connect smtp.acme.fr:25
EHLO localhost
AUTH PLAIN
AG5vbQBNT1RERVBBU1M=

On test que SSLv3 soit bien désactivé

openssl s_client -ssl3 -starttls smtp -crlf -connect smtp.acme.fr:25

http://mxtoolbox.com/diagnostic.aspx

Vérification DNS

Champs DNS : SPF DKIM ARC DMARC etc….

Voir :

$ dig acme.fr TXT @8.8.8.8 +short
"v=spf1 mx ~all"
$ dig acme.fr MX @8.8.8.8 +short
1 smtp.acme.fr.
100 smtp2.acme.fr.

Pour ne pas être considéré comme un spammer, il faut aussi créer le PTR dans le Reverse DNS. \ ip ⇒ smtp.acme.fr

Fail2ban

/etc/fail2ban/jail.local

### SSH
 
[ssh]
 
enabled  = true
port     = 7001
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 6
 
[ssh-ddos]
 
enabled  = true
port     = 7001
filter   = sshd-ddos
logpath  = /var/log/auth.log
maxretry = 6
 
### GENERIC
 
# Generic filter for pam. Has to be used with action which bans all ports
# such as iptables-allports, shorewall
[pam-generic]
 
enabled  = true
# pam-generic filter can be customized to monitor specific subset of 'tty's
filter   = pam-generic
# port actually must be irrelevant but lets leave it all for some possible uses
port     = all
banaction = iptables-allports
port     = anyport
logpath  = /var/log/auth.log
maxretry = 6
 
### MAILS
 
[postfix]
 
enabled  = true
port     = smtp,ssmtp
filter   = postfix
logpath  = /var/log/mail.log
 
 
[sasl]
 
enabled  = true
port     = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter   = sasl
# You might consider monitoring /var/log/mail.warn instead if you are
# running postfix since it would provide the same log lines at the
# "warn" level but overall at the smaller filesize.
logpath  = /var/log/mail.log
 
[dovecot]
 
enabled = true
port    = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter  = dovecot
logpath = /var/log/mail.log
service fail2ban restart
service fail2ban status

Webmail avec RoundCube

Si vous avez toujours nom@localhost au lieu de nom@domain.com il peut être nécessaire de supprimer la base de donnée sqlite (par précaution renommer le fichier sqlite (base.db dans notre exemple)

defaults.inc.php

$config['mail_domain'] = '%d';

La base de donnée (ici sqlite)

config.inc.php

$config['db_dsnw'] = 'sqlite:////var/www/roundcubemail/config/base.db?mode=0646';
apt-get install php5-fpm php5-sqlite php5-mcrypt php5-intl

/etc/php5/fpm/php.ini

date.timezone = 'Europe/Paris'

/etc/nginx/sites-available/webmail

server {
        listen 443;

        ssl on;
        ssl_certificate /etc/ssl/private/serv1.acme.fr.crt;
        ssl_certificate_key /etc/ssl/private/serv1.acme.fr.key;
        ssl_session_timeout 5m;
        ssl_prefer_server_ciphers on;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ALL:!aNULL:!eNULL:!LOW:!EXP:!RC4:!3DES:+HIGH:+MEDIUM;
        ssl_dhparam /etc/ssl/private/dh2048.pem;
        add_header Strict-Transport-Security max-age=2678400;

        root /var/www/roundcubemail;
        index index.html index.htm index.php;

        client_max_body_size 20M;
        server_name webmail.serv1.acme.fr;
        access_log  /var/log/nginx/webmail/access.log;
        error_log   /var/log/nginx/webmail/error.log;
        autoindex off;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-cgi alone:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}
ln -s /etc/nginx/sites-available/webmail /etc/nginx/sites-enabled/
nginx -t
service nginx reload
cd /etc/ssl/private/
openssl dhparam -out /etc/ssl/private/dh2048.pem -outform PEM -2 2048
 
openssl genrsa -des3 -out serv1.acme.fr.key 2048
# Ou : "openssl ecparam -genkey" pour Elliptic Curve key
openssl req -new -key serv1.acme.fr.key -out serv1.acme.fr.csr
openssl rsa -in serv1.acme.fr.key  -out  serv1.acme.fr.key.unencrypted
mv -f serv1.acme.fr.key.unencrypted serv1.acme.fr.key
chmod 600 serv1.acme.fr.key
openssl x509 -req -days 3650 -in serv1.acme.fr.csr -signkey serv1.acme.fr.key -out serv1.acme.fr.crt
chown www-data: /var/www/roundcubemail/temp
chown www-data: /var/www/roundcubemail/logs
chown www-data: /var/www/roundcubemail/config

Après avoir fait la conf sur https://webmail.serv1.acme.fr/installer

rm /var/www/roundcubemail/installer/ -rf

FIXME Bloquer les URLS: https://webmail.serv1.acme.fr/logs/errors

ln -s /var/www/roundcubemail/logs /var/log/roundcube

Extension
Tag thunderbird, couleurs en fonction des étiquettes sur les mails
cd /var/www/roundcubemail/plugins
git clone https://github.com/mike-kfed/rcmail-thunderbird-labels
chmod -R  a+rX rcmail-thunderbird-labels
mv rcmail-thunderbird-labels thunderbird_labels

config.inc.php

$config['plugins'] = array('thunderbird_labels');
Plugin zipdownload pour télécharger toutes les pièces jointes dans un fichier Zip

php_zip extension (including ZipArchive class)

apt-get install libphp-pclzip

config/config.inc.php

$config['plugins'] = array(
    'thunderbird_labels',
    'archive',
    'zipdownload',
);

Note commande postconf

postconf -d ; Affiche les valeurs par défaut à la place de la conf actuelle.

-n Print main.cf parameter settings that are explicitly specified in main.cf. Specify -nf to fold long lines for human readability

postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
bounce_queue_lifetime = 1d
bounce_size_limit = 2000
broken_sasl_auth_clients = no
config_directory = /etc/postfix
disable_vrfy_command = yes
home_mailbox = Maildir/
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
maximal_queue_lifetime = 1d
mydestination = $mydomain, localhost.$mydomain, localhost
myhostname = serv1.acme.fr
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.16.0.0/12
mynetworks_style = host
myorigin = /etc/mailname
policy-spf_time_limit = 3600s
readme_directory = no
recipient_delimiter = +
relayhost =
show_user_unknown_table_name = no
smtp_tls_mandatory_protocols = !SSLv2,!SSLv3
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = !SSLv2,!SSLv3
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = Every illegal access will be referred to the appropriate authorities and the CERT.
smtpd_client_message_rate_limit = 3
smtpd_data_restrictions = reject_unauth_pipelining, reject_multi_recipient_bounce, permit
smtpd_delay_reject = yes
smtpd_error_sleep_time = 10
smtpd_etrn_restrictions = permit_mynetworks, reject
smtpd_hard_error_limit = 5
smtpd_helo_required = yes
smtpd_helo_restrictions = reject_non_fqdn_helo_hostname, reject_unknown_helo_hostname, warn_if_reject reject_invalid_hostname
smtpd_junk_command_limit = 3
smtpd_recipient_restrictions = reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_multi_recipient_bounce, reject_non_fqdn_hostname, reject_invalid_hostname, reject_unknown_client, warn_if_reject reject_unknown_hostname, reject_unauth_pipelining, reject_rhsbl_sender dsn.rfc-ignorant.org reject_rhsbl_sender bogusmx.rfc-ignorant.org, reject_rbl_client bl.spamcop.net, reject_rbl_client sbl-xbl.spamhaus.org, reject_rbl_client dnsbl.sorbs.net, reject_rbl_client zen.spamhaus.org, check_policy_service unix:private/policy-spf, permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_sasl_tls_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unknown_address
smtpd_soft_error_limit = 2
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
smtpd_tls_protocols = !SSLv2,!SSLv3
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
strict_rfc821_envelopes = yes
tls_random_source = dev:/dev/urandom
2025/03/24 15:06

Console câble série croisé RS-232

Voir aussi Console iDRAC / ILO

/etc/inittab

SO:12345:respawn:/sbin/getty -L 19200 ttyS0 vt102

/etc/default/grub

GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
update-grub

Pour prendre la console depuis le 2em PC raccordé avec la câble série croisé (RS-232)

screen /dev/ttyS0 115200

Autre

SystemD

Brouillon

Voir https://freedesktop.org/wiki/Software/systemd/Debugging/

Boot parameter

systemd.journald.forward_to_console=1 console=ttyS0,38400
systemctl enable serial-getty@ttyS0.service
Notes
earlyprintk=ttyS0 console=ttyS0,9600n8 nousb noplymouth ip=:::::eth0: boot=local
2025/03/24 15:06

Dokuwiki - Strata semi-structured data

Intro

Voir :

DokuWiki utilise des fichiers plats, nul besoin de base de données relationnelle. Cependant il peut être utile d'utiliser des données structurées, sémantique et autre.

Une solution intéressante est l’extension Strata (semi-structured data) qui utilise par défaut sqlite (possibilité d'utiliser PostgreSQL ou MySQL).

Nous avons que les avantages d'une base de données relationnelle, sans les inconvénients. En effet, toutes les données sont dans les pages du Wiki au format texte. Un effacement de la base ne serait donc pas catastrophique !

Install

Nécessite l’extension DokuWiki sqlite

Module PHP pour communiquer avec sqlite. Sur Debian :

apt-get install php5-sqlite

Install sur alpine / PHP7

apk add php7-sqlite3 sqlite php7-pdo_sqlite

Note fichier :

Conf DW sqlite:@METADIR@/strata.sqlite3
Emplacement ./data/meta/strata.sqlite3

Notes

Pour commenter une ligne, préfixer là par “--” comme en SQL

Les données ne peuvent être saisi que par la balise <data> Pour requêter il existe les balises <table> et <list>

Exemple

Données

Création d'un page sur DokuWiki

people:alice_king

<data person>
Full Name: Alice King
Birthday [date::Y-m-d]: 1985-11-12
Birthplace [page::places]: London
Contact [link]: alice.king@example.org
Friends [ref]*: Bob Marley, Jean Paul
</data>

page people:bob_marley

<data person>
Full Name: Bob Marley
Birthday [date::Y-m-d]: 1945-02-06
Birthplace [page::places]: Nine Miles
Contact [link]:
Friends [ref]*: Alice King, Jean Paul
</data>

NB : Le ligne Contact [link]: ne contenant aucune valeur sera ignorée, elle ne sert à rien

La syntaxe basée sur SPARQL est assez simple pour la saisi de donnés.

<data nomDeLaTable>

-- Les lignes commençant par -- sont ignorées

-- Exemple
Clef: Valeur

-- Ou
Clef [type]: valeur

-- Ou encore
-- Le symbole "*" signifie que plusieurs valeurs sont possibles
Clef [type]*: valeur

Clef [type::hint]: valeur
-- Exemple
DateFacture [date::Y-m-d]: 2016-03-04
</data>

Le type sert à la fois au stockage des données ainsi qu'à la présentation

Requête

Sur une autre page

~~NOCACHE~~

<table ?p "Person" ?birthday "Birthday" ?birthplace "Birthplace" ?contact "Contact">
?p is a: person
?p Contact [link]: ?contact
?p Birthday [date]: ?birthday
?p Birthplace  [page::places]: ?birthplace
</table> 

Bob Marley n’apparaît pas. Ce n'est pas parce que vous n'avez pas assez fumé. En fait ici tous les champs demandés sont obligatoires alors que le champ Contact est vide

Réécrivons notre requête avec le champ Contact optionnel

<table ?p "Person" ?birthday "Birthday" ?birthplace "Birthplace" ?contact "Contact">
?p is a: person

optional {
  ?p Contact [link]: ?contact
} 

?p Birthday [date]: ?birthday
?p Birthplace  [page::places]: ?birthplace
</table> 

Exemple avec Union

<table ?p "Person" ?birthday "Birthday" ?birthplace "Birthplace" ?contact "Contact">
?p is a: person

optional {
  ?p Contact [link]: ?contact
}

?p Birthday [date]: ?birthday

--Lignes commentées
--?p Birthplace  [page::places]: ?birthplace
--?birthplace = London

union {
  {
    ?p Birthplace  [page::places]: ?birthplace
    ?birthplace = London
  }
  
  {
    ?p Birthplace  [page::places]: ?birthplace
    ?birthplace = Nine Miles
  }
}
</table>
2025/03/24 15:06

Docker-compose

Voir :

  • podman-compose
  • /usr/libexec/docker/cli-plugins/docker-compose

docker-compose.yml

version: "3.7"

services:

  memcached:
    image: memcached:1.5.19-alpine
    container_name: pm-memcached
    ports:
     - "11211"
    networks:
     - backend
    restart: unless-stopped

  php:
    image: acme/app1-www:1.01.02
    container_name: pm-www
    volumes:
     - src:/opt/acme/dir1/app1
     - /mnt/data:/mnt/data
    ports:
     - "8000"
    networks:
     - backend
    restart: unless-stopped
    depends_on:
     - memcached

  httpd:
    image: acme/app1-httpd:1.01.02
    container_name: pm-httpd
    volumes:
     - src:/opt/acme/dir1/app1
     - /var/log/app1:/var/log/app1
    ports:
     - "443:443"
    networks:
     - backend
    restart: unless-stopped
    depends_on:
     - php

networks:
  backend:
#    ipam:
#      driver: default
#      config:
#        - subnet: 192.168.10.0/24

volumes:
  src:

docker-compose.yml

version: "3.7"

services:
  webapp:
    build:
      context: .
      args:
        - http_proxy=http://192.168.56.1:3128
        - https_proxy=http://192.168.56.1:3128
    network_mode: "host"

docker-compose.yml

version: "3.7"

services:
  webapp:
    image: webapp
    container_name: webapp1
    network_mode: "host"
docker-compose build --no-cache
docker-compose up

Autres

    volumes:
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"

host-bind sur un fichier qui ne soit pas un dossier :

volumes:
  - type: bind
    read_only: True
    source: ./sourceFile.yaml
    target: /location/targetFile.yaml
Utiliser les Profiles

docker-compose.yml

---

services:
  app_plop:
    container_name: app_plop
    profiles:
      - n
    image: "${CTN_app_plop_IMAGE}"
    hostname: l12app_plop03
    restart: "always"
    network_mode: host
    volumes:
      - {'type': 'bind', 'read_only': True, 'source': '/etc/timezone', 'target': '/etc/timezone'}
      - {'type': 'bind', 'read_only': True, 'source': '/etc/localtime', 'target': '/etc/localtime'}
      - /data/data:/home/app/data

.env

CTN_app_plop_IMAGE="registry.acme.local/repository/docker-local/app_plop:l13-p3.3.12-d10.1.2-v1.0"
docker-compose --profile='*' pull
 
docker-compose --profile n config > docker-compose2.yml
 
docker-compose --profile n up
Ansible

env.jinja

{% for container in containers %}
CTN_{{ container.container_name }}_IMAGE="{{ container.container_image }}"
{% endfor %}

docker-compose.yml.jinja

---

services:
{% for container in containers %}
  {{ container.container_name }}:
    container_name: {{ container.container_name }}
    profiles:
    {%- for profile in container.profiles +%}
      - {{ profile }}
    {%- endfor +%}
    image: "${CTN_{{ container.container_name }}_IMAGE}"
    hostname: {{ container.container_hostname }}
    restart: "{{ container.container_restart_policy }}"
    network_mode: {{ container.network }}
    volumes:
    {%- for volume in container.container_mounts +%}
      - {{ volume }}
    {%- endfor +%}
- name: Template docker-compose.yml
  ansible.builtin.template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    mode: "0640"
  loop:
    - {src: 'docker-compose.yml.jinja', dest: '/opt/compose/docker-compose.yml'}
    - {src: 'env.jinja', dest: '/opt/compose/.env'}

- name: Pull images
  community.docker.docker_compose_v2_pull:
    project_src: /opt/compose/
    profiles:
      - '*'

- name: Deploy app with Docker Compose
  community.docker.docker_compose_v2:
    project_src: /opt/compose/
    state: present
    profiles:
      - n

Pb

docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object
# mount -o remount,noexec /tmp
# docker-compose
docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object
Solution
mkdir /plop
chmod 1777 /plop                  
export TMPDIR=/plop                  
docker-compose

Faire un wrapper

mv /usr/local/bin/docker-compose /usr/local/bin/docker-compose-bin

/usr/local/bin/docker-compose

#! /bin/bash
 
DIR=$(dirname "$(realpath "$0")")
TMPDIR=/tmp2
 
if [ ! -d "$TMPDIR" ]
then
        mkdir "$TMPDIR"
        chmod 1777 "$TMPDIR"
fi
 
export TMPDIR
${DIR}/docker-compose-bin "$@"
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