最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】CentOS中禁止掉邮件服务dovecot和postfix

CentOS crifan 9573浏览 0评论

之前在Linode的VPS中安装了邮件服务器的服务:

postfix和dovecot

后来不用了,换成了163的免费企业有了:

【记录】给crifan.com的邮件服务器安装垃圾过滤系统

现在不用自己的邮件服务器了,要去禁止掉对应的服务。

 

【记录】

记不太清命令了。

去找到:

systemd – ArchWiki

然后搞定了:

crifan@crifan:~$ service postfix status
Redirecting to /bin/systemctl status  postfix.service
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2016-05-09 22:54:40 CST; 1 weeks 3 days ago
  Process: 3552 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  Process: 3545 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 3509 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
 Main PID: 4000 (master)
   CGroup: /system.slice/postfix.service
           ├─ 4000 /usr/libexec/postfix/master -w
           ├─ 4002 qmgr -l -t unix -u
           ├─ 4947 tlsmgr -l -t unix -u
           └─10534 pickup -l -t unix -u
crifan@crifan:~$ systemctl postfix disable
Unknown operation 'postfix'.
crifan@crifan:~$ systemctl disable postfix
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
crifan@crifan:~$ sudo systemctl disable postfix
[sudo] password for crifan: 
crifan@crifan:~$ sudo systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2016-05-09 22:54:40 CST; 1 weeks 3 days ago
 Main PID: 4000 (master)
   CGroup: /system.slice/postfix.service
           ├─ 4000 /usr/libexec/postfix/master -w
           ├─ 4002 qmgr -l -t unix -u
           ├─ 4947 tlsmgr -l -t unix -u
           └─10534 pickup -l -t unix -u

May 20 12:53:13 crifan.com postfix/pipe[4309]: 374923D80: to=<[email protected]>, relay=dovecot, delay=1.3, delays=1.3/0.02/0/...rvice)
May 20 12:53:13 crifan.com postfix/qmgr[4002]: 374923D80: removed
May 20 12:53:13 crifan.com postfix/smtpd[4297]: disconnect from unknown[58.39.241.228]
May 20 13:00:19 crifan.com postfix/smtpd[5604]: warning: hostname no-reverse-dns-configured.com does not resolve to address 8...62.175
May 20 13:00:19 crifan.com postfix/smtpd[5604]: connect from unknown[89.248.162.175]
May 20 13:00:19 crifan.com postfix/smtpd[5604]: warning: unknown[89.248.162.175]: SASL LOGIN authentication failed: Invalid a...hanism
May 20 13:00:19 crifan.com postfix/smtpd[5604]: disconnect from unknown[89.248.162.175]
May 20 13:03:39 crifan.com postfix/anvil[5606]: statistics: max connection rate 1/60s for (smtp:89.248.162.175) at May 20 13:00:19
May 20 13:42:05 crifan.com postfix/smtpd[11181]: connect from 220-244-5-154.static.tpgi.com.au[220.244.5.154]
May 20 13:42:06 crifan.com postfix/smtpd[11181]: disconnect from 220-244-5-154.static.tpgi.com.au[220.244.5.154]
Hint: Some lines were ellipsized, use -l to show in full.
crifan@crifan:~$ sudo systemctl help
This command expects one or more unit names. Did you mean --help?
crifan@crifan:~$ systemctl --help
systemctl [OPTIONS...] {COMMAND} ...

Query or send control commands to the systemd manager.

  -h --help           Show this help
     --version        Show package version
     --system         Connect to system manager
  -H --host=[USER@]HOST
                      Operate on remote host
  -M --machine=CONTAINER
                      Operate on local container
  -t --type=TYPE      List units of a particular type
     --state=STATE    List units with particular LOAD or SUB or ACTIVE state
  -p --property=NAME  Show only properties by this name
  -a --all            Show all loaded units/properties, including dead/empty
                      ones. To list all units installed on the system, use
                      the 'list-unit-files' command instead.
  -l --full           Don't ellipsize unit names on output
  -r --recursive      Show unit list of host and local containers
     --reverse        Show reverse dependencies with 'list-dependencies'
     --job-mode=MODE  Specify how to deal with already queued jobs, when
                      queueing a new job
     --show-types     When showing sockets, explicitly show their type
  -i --ignore-inhibitors
                      When shutting down or sleeping, ignore inhibitors
     --kill-who=WHO   Who to send signal to
  -s --signal=SIGNAL  Which signal to send
     --now            Start or stop unit in addition to enabling or disabling it
  -q --quiet          Suppress output
     --no-block       Do not wait until operation finished
     --no-wall        Don't send wall message before halt/power-off/reboot
     --no-reload      Don't reload daemon after en-/dis-abling unit files
     --no-legend      Do not print a legend (column headers and hints)
     --no-pager       Do not pipe output into a pager
     --no-ask-password
                      Do not ask for system passwords
     --global         Enable/disable unit files globally
     --runtime        Enable unit files only temporarily until next reboot
  -f --force          When enabling unit files, override existing symlinks
                      When shutting down, execute action immediately
     --preset-mode=   Apply only enable, only disable, or all presets
     --root=PATH      Enable unit files in the specified root directory
  -n --lines=INTEGER  Number of journal entries to show
  -o --output=STRING  Change journal output mode (short, short-iso,
                              short-precise, short-monotonic, verbose,
                              export, json, json-pretty, json-sse, cat)
     --plain          Print unit dependencies as a list instead of a tree

Unit Commands:
  list-units [PATTERN...]         List loaded units
  list-sockets [PATTERN...]       List loaded sockets ordered by address
  list-timers [PATTERN...]        List loaded timers ordered by next elapse
  start NAME...                   Start (activate) one or more units
  stop NAME...                    Stop (deactivate) one or more units
  reload NAME...                  Reload one or more units
  restart NAME...                 Start or restart one or more units
  try-restart NAME...             Restart one or more units if active
  reload-or-restart NAME...       Reload one or more units if possible,
                                  otherwise start or restart
  reload-or-try-restart NAME...   Reload one or more units if possible,
                                  otherwise restart if active
  isolate NAME                    Start one unit and stop all others
  kill NAME...                    Send signal to processes of a unit
  is-active PATTERN...            Check whether units are active
  is-failed PATTERN...            Check whether units are failed
  status [PATTERN...|PID...]      Show runtime status of one or more units
  show [PATTERN...|JOB...]        Show properties of one or more
                                  units/jobs or the manager
  cat PATTERN...                  Show files and drop-ins of one or more units
  set-property NAME ASSIGNMENT... Sets one or more properties of a unit
  help PATTERN...|PID...          Show manual for one or more units
  reset-failed [PATTERN...]       Reset failed state for all, one, or more
                                  units
  list-dependencies [NAME]        Recursively show units which are required
                                  or wanted by this unit or by which this
                                  unit is required or wanted

Unit File Commands:
  list-unit-files [PATTERN...]    List installed unit files
  enable NAME...                  Enable one or more unit files
  disable NAME...                 Disable one or more unit files
  reenable NAME...                Reenable one or more unit files
  preset NAME...                  Enable/disable one or more unit files
                                  based on preset configuration
  preset-all                      Enable/disable all unit files based on
                                  preset configuration
  is-enabled NAME...              Check whether unit files are enabled
  mask NAME...                    Mask one or more units
  unmask NAME...                  Unmask one or more units
  link PATH...                    Link one or more units files into
                                  the search path
  add-wants TARGET NAME...        Add 'Wants' dependency for the target
                                  on specified one or more units
  add-requires TARGET NAME...     Add 'Requires' dependency for the target
                                  on specified one or more units
  edit NAME...                    Edit one or more unit files
  get-default                     Get the name of the default target
  set-default NAME                Set the default target

Machine Commands:
  list-machines [PATTERN...]      List local containers and host

Job Commands:
  list-jobs [PATTERN...]          List jobs
  cancel [JOB...]                 Cancel all, one, or more jobs

Snapshot Commands:
  snapshot [NAME]                 Create a snapshot
  delete NAME...                  Remove one or more snapshots

Environment Commands:
  show-environment                Dump environment
  set-environment NAME=VALUE...   Set one or more environment variables
  unset-environment NAME...       Unset one or more environment variables
  import-environment [NAME...]    Import all or some environment variables

Manager Lifecycle Commands:
  daemon-reload                   Reload systemd manager configuration
  daemon-reexec                   Reexecute systemd manager

System Commands:
  is-system-running               Check whether system is fully running
  default                         Enter system default mode
  rescue                          Enter system rescue mode
  emergency                       Enter system emergency mode
  halt                            Shut down and halt the system
  poweroff                        Shut down and power-off the system
  reboot [ARG]                    Shut down and reboot the system
  kexec                           Shut down and reboot the system with kexec
  exit                            Request user instance exit
  switch-root ROOT [INIT]         Change to a different root file system
  suspend                         Suspend the system
  hibernate                       Hibernate the system
  hybrid-sleep                    Hibernate and suspend the system
crifan@crifan:~$ sudo systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2016-05-09 22:54:40 CST; 1 weeks 3 days ago
 Main PID: 4000 (master)
   CGroup: /system.slice/postfix.service
           ├─ 4000 /usr/libexec/postfix/master -w
           ├─ 4002 qmgr -l -t unix -u
           ├─ 4947 tlsmgr -l -t unix -u
           └─10534 pickup -l -t unix -u

May 20 12:53:13 crifan.com postfix/pipe[4309]: 374923D80: to=<[email protected]>, relay=dovecot, delay=1.3, delays=1.3/0.02/0/...rvice)
May 20 12:53:13 crifan.com postfix/qmgr[4002]: 374923D80: removed
May 20 12:53:13 crifan.com postfix/smtpd[4297]: disconnect from unknown[58.39.241.228]
May 20 13:00:19 crifan.com postfix/smtpd[5604]: warning: hostname no-reverse-dns-configured.com does not resolve to address 8...62.175
May 20 13:00:19 crifan.com postfix/smtpd[5604]: connect from unknown[89.248.162.175]
May 20 13:00:19 crifan.com postfix/smtpd[5604]: warning: unknown[89.248.162.175]: SASL LOGIN authentication failed: Invalid a...hanism
May 20 13:00:19 crifan.com postfix/smtpd[5604]: disconnect from unknown[89.248.162.175]
May 20 13:03:39 crifan.com postfix/anvil[5606]: statistics: max connection rate 1/60s for (smtp:89.248.162.175) at May 20 13:00:19
May 20 13:42:05 crifan.com postfix/smtpd[11181]: connect from 220-244-5-154.static.tpgi.com.au[220.244.5.154]
May 20 13:42:06 crifan.com postfix/smtpd[11181]: disconnect from 220-244-5-154.static.tpgi.com.au[220.244.5.154]
Hint: Some lines were ellipsized, use -l to show in full.
crifan@crifan:~$ sudo systemctl stop postfix  
crifan@crifan:~$ sudo systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

May 20 13:00:19 crifan.com postfix/smtpd[5604]: warning: unknown[89.248.162.175]: SASL LOGIN authentication failed: Invalid a...hanism
May 20 13:00:19 crifan.com postfix/smtpd[5604]: disconnect from unknown[89.248.162.175]
May 20 13:03:39 crifan.com postfix/anvil[5606]: statistics: max connection rate 1/60s for (smtp:89.248.162.175) at May 20 13:00:19
May 20 13:42:05 crifan.com postfix/smtpd[11181]: connect from 220-244-5-154.static.tpgi.com.au[220.244.5.154]
May 20 13:42:06 crifan.com postfix/smtpd[11181]: disconnect from 220-244-5-154.static.tpgi.com.au[220.244.5.154]
May 20 14:02:27 crifan.com systemd[1]: Stopping Postfix Mail Transport Agent...
May 20 14:02:27 crifan.com postfix[14578]: /usr/sbin/postconf: warning: /etc/postfix/main.cf: undefined parameter: virtual_m...it_maps
May 20 14:02:27 crifan.com postfix[14578]: /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: virtual_crea...ize=yes
May 20 14:02:27 crifan.com postfix[14578]: /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: virtual_mail...ded=yes
May 20 14:02:27 crifan.com systemd[1]: Stopped Postfix Mail Transport Agent.
Hint: Some lines were ellipsized, use -l to show in full.
crifan@crifan:~$ sudo systemctl status dovecot
● dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2016-05-09 22:55:10 CST; 1 weeks 3 days ago
 Main PID: 4142 (dovecot)
   CGroup: /system.slice/dovecot.service
           ├─ 4142 /usr/sbin/dovecot -F
           ├─ 4147 dovecot/anvil
           ├─ 4148 dovecot/log
           └─11185 dovecot/config

May 18 16:13:44 crifan.com dovecot[4148]: pop3-login: Aborted login (tried to use disallowed plaintext auth): user=<>, rip=1...CmPimE>
May 18 16:13:44 crifan.com dovecot[4148]: pop3-login: Aborted login (tried to use disallowed plaintext auth): user=<>, rip=1...CmPimE>
May 18 16:13:44 crifan.com dovecot[4148]: pop3-login: Aborted login (tried to use disallowed plaintext auth): user=<>, rip=1...CmPimE>
May 18 16:13:44 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=166.62.41.132,...CmPimE>
May 18 16:13:44 crifan.com dovecot[4148]: pop3-login: Aborted login (tried to use disallowed plaintext auth): user=<>, rip=1...CmPimE>
May 19 14:53:45 crifan.com dovecot[4148]: imap-login: Disconnected (disconnected before auth was ready, waited 0 secs): user...CN1HqB>
May 19 23:50:16 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=141.212.122.81...CN1HpR>
May 20 02:20:19 crifan.com dovecot[4148]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=54.186.221.62,...A2ut0+>
May 20 06:39:19 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=54.67.0.110, l...A2QwBu>
May 20 13:21:06 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=89.248.172.154...BZ+Kya>
Hint: Some lines were ellipsized, use -l to show in full.
crifan@crifan:~$ sudo systemctl stop dovecot
crifan@crifan:~$ sudo systemctl status dovecot
● dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Fri 2016-05-20 14:02:49 CST; 2s ago
 Main PID: 4142 (code=exited, status=0/SUCCESS)

May 18 16:13:44 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=166.62.41.132,...CmPimE>
May 18 16:13:44 crifan.com dovecot[4148]: pop3-login: Aborted login (tried to use disallowed plaintext auth): user=<>, rip=1...CmPimE>
May 19 14:53:45 crifan.com dovecot[4148]: imap-login: Disconnected (disconnected before auth was ready, waited 0 secs): user...CN1HqB>
May 19 23:50:16 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=141.212.122.81...CN1HpR>
May 20 02:20:19 crifan.com dovecot[4148]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=54.186.221.62,...A2ut0+>
May 20 06:39:19 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=54.67.0.110, l...A2QwBu>
May 20 13:21:06 crifan.com dovecot[4148]: pop3-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=89.248.172.154...BZ+Kya>
May 20 14:02:49 crifan.com dovecot[4142]: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
May 20 14:02:49 crifan.com systemd[1]: Stopping Dovecot IMAP/POP3 email server...
May 20 14:02:49 crifan.com systemd[1]: Stopped Dovecot IMAP/POP3 email server.
Hint: Some lines were ellipsized, use -l to show in full.
crifan@crifan:~$ sudo systemctl disable dovecot
Removed symlink /etc/systemd/system/multi-user.target.wants/dovecot.service.
crifan@crifan:~$ sudo systemctl disable postfix
crifan@crifan:~$ sudo systemctl is-enabled postfix
disabled
crifan@crifan:~$ sudo systemctl is-enabled dovecot
disabled 

另外,另外也去试了试其它命令:

systemctl list-units

systemctl status

然后再去重启服务器:

 

linode reboot vps server after disable mail services

 

之后再去确认服务是否被真的关闭不允许了:

crifan@crifan:~$ sudo systemctl is-enabled dovecot      
[sudo] password for crifan: 
disabled
crifan@crifan:~$ sudo systemctl is-enabled postfix
disabled
crifan@crifan:~$ systemctl status dovecot
● dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
crifan@crifan:~$ systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

【总结】

CentOS中禁止掉邮件服务:dovecot和postfix:

sudo systemctl stop dovecot
sudo systemctl stop postfix
sudo systemctl disable dovecot
sudo systemctl disable postfix

在操作之前和之后,可以查看状态:

systemctl status dovecot
systemctl status postfix

和:

systemctl is-enabled dovecot
systemctl is-enabled postfix

以及重启系统后,再去确认:

systemctl status dovecot
systemctl status postfix

和:

systemctl is-enabled dovecot
systemctl is-enabled postfix

转载请注明:在路上 » 【记录】CentOS中禁止掉邮件服务dovecot和postfix

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.218 seconds, using 22.12MB memory