Envoyer des emails avec postfix

xunil2003 Messages postés 766 Date d'inscription   Statut Membre Dernière intervention   -  
roptat Messages postés 284 Statut Membre -
Bonjour,

Je n'arrive pas a envoyer les email depuis postfix, je me tire les cheveux ?
Mon FAI est Free.
Dans la configuration de la freebox , le blocage de smtp sortant est activé.
Pouvez vous m'aider, je suis sur Debian Squeeze ?
Merci.

Fichier /etc/postfix/main.cf
root@debian:~# cat  /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)
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/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

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

#myhostname = debian
myhostname = free.fr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#mydestination = debian, localhost.localdomain, , localhost
mydestination = debian, free.fr, localhost.localdomain, , localhost

relayhost = [smtp.free.fr]
#relayhost = [free.fr]
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
root@debian:~#


Rèsultat postconf -n
root@debian:~# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = ipv4
mailbox_size_limit = 30000
mydestination = debian, free.fr, localhost.localdomain, , localhost
myhostname = free.fr
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
readme_directory = no
recipient_delimiter = +
relayhost = [smtp.free.fr]
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
root@debian:~#


root@debian:~# cat /etc/hostname
debian
root@debian:~# cat /etc/mailname
debian


Merci.

6 réponses

  1. xunil2003 Messages postés 766 Date d'inscription   Statut Membre Dernière intervention   14
     
    Bonsoir,

    J'ai modifié la config de la freebox.
    Dans la configuration de la freebox , le blocage de smtp sortant est : Inactif.

    Mais hélas je n'arrive toujours pas a envoyer des emails.
    echo ceci est un test $(date +%H:%M) | mail -v -s "test envoi mail" mon_email@free.fr


    Merci.
    1
  2. axel55 Messages postés 113 Statut Membre 14
     
    Bonjour, je ne suis pas un spécialiste en la matière, mais si le proto smtp est bloqué par la box, les courriels ne peuvent pas partir non?
    0
  3. xunil2003 Messages postés 766 Date d'inscription   Statut Membre Dernière intervention   14
     
    Bonsoir,

    J'ai trouvé ça marche comme ceci : y compris les adresse free et gmail.
    Mais j'ai une question cela ne craint-il pas de désactiver l'option smtp sortant de Free.
    Cette option doit nous protéger ?
    Pour un serveur ne vaut-il pas mieux réactiver l'option Smtp sortant ?

    Moi c'est pour mon serveur que je l'ai fait, afin d'être averti par email, si quelqu'un se connecte à mon système, des emails seront envoyés à des adresses free.fr et gmail.com.

    Car j'ai un nombre incroyable de tentatives de loger sur le root dans le fichier
    /var/log/auth.log
    avec des ip extérieur que je ne connais même pas, alors c'est plutôt dangereux de désactiver l'option de free . Non !
    Merci .

    Feb 24 18:14:28 debian sshd[3329]: Failed password for invalid user tomcat from 222.92.216.12 port 47538 ssh2 
    Feb 24 18:17:07 debian sshd[3425]: Failed password for invalid user oracle from 222.92.216.12 port 56330 ssh2 
    Feb 24 18:17:58 debian sshd[3472]: Failed password for invalid user nagios from 222.92.216.12 port 40161 ssh2 
    Feb 24 18:34:45 debian sshd[4127]: Failed password for root from 222.92.216.12 port 39872 ssh2 
    Feb 24 18:34:49 debian sshd[4129]: Failed password for invalid user roots from 222.92.216.12 port 41009 ssh2 
    
    Feb 24 18:39:03 debian sshd[4275]: Failed password for root from 222.92.216.12 port 34776 ssh2 
    Feb 24 18:39:08 debian sshd[4285]: Failed password for invalid user roottest from 222.92.216.12 port 35826 ssh2 
    
    Feb 24 18:42:26 debian sshd[4369]: Failed password for invalid user rootuser from 222.92.216.12 port 53263 ssh2 
    Feb 24 18:42:30 debian sshd[4371]: Failed password for invalid user rootuser from 222.92.216.12 port 54396 ssh2 
    Feb 24 18:42:35 debian sshd[4373]: Failed password for root from 222.92.216.12 port 55404 ssh2 
    Feb 24 18:42:40 debian sshd[4375]: Failed password for root from 222.92.216.12 port 56540 ssh2 
    Feb 24 18:42:44 debian sshd[4377]: Failed password for root from 222.92.216.12 port 57701 ssh2 
    Feb 24 18:48:23 debian sshd[4550]: Failed password for root from 222.92.216.12 port 57815 ssh2 
    Feb 24 18:48:28 debian sshd[4569]: Failed password for bin from 222.92.216.12 port 45241 ssh2 
    Feb 24 19:16:14 debian sshd[5456]: Failed password for root from 222.92.216.12 port 42249 ssh2 
    Feb 24 19:16:20 debian sshd[5458]: Failed password for root from 222.92.216.12 port 43294 ssh2 
    Feb 24 19:16:26 debian sshd[5460]: Failed password for root from 222.92.216.12 port 44636 ssh2 
    Feb 24 19:16:31 debian sshd[5462]: Failed password for root from 222.92.216.12 port 45692 ssh2 
    Feb 24 19:16:41 debian sshd[5464]: Failed password for root from 222.92.216.12 port 46854 ssh2
    Je ne vais pas tous mettre

    Mais voici le nombre de tentative :
    root@debian:~# expr 'zcat /var/log/auth.log*gz | grep -c "authentication failure"' + ' cat /var/log/auth.log* | grep -c "authentication failure"' 
    22620 
    root@debian:~#  


    ça marche avec mon fichier /etc/postfix/main.cf configurer comme ceci :
    root@debian:~# cat  /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) 
    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/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 
    
    # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for 
    # information on enabling SSL in the smtp client. 
    
    myhostname = free.fr 
    alias_maps = hash:/etc/aliases 
    alias_database = hash:/etc/aliases 
    mydestination = debian, smtp.free.fr, localhost.localdomain, , localhost 
    
    relayhost = smtp.free.fr 
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 
    mailbox_size_limit = 30000 
    recipient_delimiter = + 
    inet_interfaces = all 
    inet_protocols = ipv4 
    root@debian:~#  
    


    Merci.
    0
  4. roptat Messages postés 284 Statut Membre 77
     
    J'ai aussi un serveur (derrière une live box) et j'ai eu du mal à faire passer mes mails. L'option de blocage smtp sortant ne te protège en rien : c'est une option du FAI pour se protéger lui-même (bloquer les machines zombies qui envoient des pourriels à tour de bras). La désactiver ne diminuera pas ta sécurité.
    Maintenant, pour les tentatives de connection sur ta machine, sois tu désinstalle openssh-server, soit si tu en as besoin, tu modifie le port d'écoute (dans /etc/ssh(d)/ssh(d)_config ou un truc du genre). Les tentatives de connection sont faites par des robots (des ordinateurs zombies) qui pour la plupart n'essaient pas de passer par d'autres ports.
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. xunil2003
     
    Bonjour,

    Je suis obligé de garder la connexion ssh pour l'accès au serveur.
    Donc pour modifier le port ssh j'édite le fichier
    /etc/ssh/sshd_config
    
    puis je modifie le numéro du port (ici 22) de la ligne 5 par un autre.
    Puis je redémarre le service
    # service ssh restart

    et j'ajoute le numéro du port dans le parefeu de iptables
    Je ne sais pas comment l'ajouter dans iptables ???
    Es-ce corect
    Merci.

    Contenu du fichier etc/ssh/sshd_config
    root@debian:~# cat -n  /etc/ssh/sshd_config
         1  # Package generated configuration file
         2  # See the sshd_config(5) manpage for details
         3
         4  # What ports, IPs and protocols we listen for
         5  Port 22
         6  # Use these options to restrict which interfaces/protocols sshd will bind to
         7  #ListenAddress ::
         8  #ListenAddress 0.0.0.0
         9  Protocol 2
        10  # HostKeys for protocol version 2
        11  HostKey /etc/ssh/ssh_host_rsa_key
        12  HostKey /etc/ssh/ssh_host_dsa_key
        13  #Privilege Separation is turned on for security
        14  UsePrivilegeSeparation yes
        15
        16  # Lifetime and size of ephemeral version 1 server key
        17  KeyRegenerationInterval 3600
        18  ServerKeyBits 768
        19
        20  # Logging
        21  SyslogFacility AUTH
        22  LogLevel INFO
        23
        24  # Authentication:
        25  LoginGraceTime 120
        26  PermitRootLogin yes
        27  StrictModes yes
        28
        29  RSAAuthentication yes
        30  PubkeyAuthentication yes
        31  #AuthorizedKeysFile     %h/.ssh/authorized_keys
        32
        33  # Don't read the user's ~/.rhosts and ~/.shosts files
        34  IgnoreRhosts yes
        35  # For this to work you will also need host keys in /etc/ssh_known_hosts
        36  RhostsRSAAuthentication no
        37  # similar for protocol version 2
        38  HostbasedAuthentication no
        39  # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
        40  #IgnoreUserKnownHosts yes
        41
        42  # To enable empty passwords, change to yes (NOT RECOMMENDED)
        43  PermitEmptyPasswords no
        44
        45  # Change to yes to enable challenge-response passwords (beware issues with
        46  # some PAM modules and threads)
        47  ChallengeResponseAuthentication no
        48
        49  # Change to no to disable tunnelled clear text passwords
        50  #PasswordAuthentication yes
        51
        52  # Kerberos options
        53  #KerberosAuthentication no
        54  #KerberosGetAFSToken no
        55  #KerberosOrLocalPasswd yes
        56  #KerberosTicketCleanup yes
        57
        58  # GSSAPI options
        59  #GSSAPIAuthentication no
        60  #GSSAPICleanupCredentials yes
        61
        62  X11Forwarding yes
        63  X11DisplayOffset 10
        64  PrintMotd no
        65  PrintLastLog yes
        66  TCPKeepAlive yes
        67  #UseLogin no
        68
        69  #MaxStartups 10:30:60
        70  #Banner /etc/issue.net
        71
        72  # Allow client to pass locale environment variables
        73  AcceptEnv LANG LC_*
        74
        75  Subsystem sftp /usr/lib/openssh/sftp-server
        76
        77  # Set this to 'yes' to enable PAM authentication, account processing,
        78  # and session processing. If this is enabled, PAM authentication will
        79  # be allowed through the ChallengeResponseAuthentication and
        80  # PasswordAuthentication.  Depending on your PAM configuration,
        81  # PAM authentication via ChallengeResponseAuthentication may bypass
        82  # the setting of "PermitRootLogin without-password".
        83  # If you just want the PAM account and session checks to run without
        84  # PAM authentication, then enable this but set PasswordAuthentication
        85  # and ChallengeResponseAuthentication to 'no'.
        86  UsePAM yes
    root@debian:~# 


    Merci.
    0
  7. roptat Messages postés 284 Statut Membre 77
     
    C'est ça. la commande pour iptables, c'est
    /sbin/iptables -A INPUT -i eth0 --dport 22 -j ACCEPT

    ( http://doc.ubuntu-fr.org/iptables )

    remplace 22 par le numéro de port et INPUT éventuellement par OUTPUT suivant les valeurs par défauts (regarde iptables -L)
    0