1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

dovecotがインストールされているサーバーでtelnetをしてもログインできない

Posted at

#はじめに
dovecotがインストールされているサーバーでtelnetをしてもログインできなかった際の対応と解決策の備忘録として執筆します。

#前提
postfixを構築し、dovecotでメールの受信ができるかのテストを実施
ユーザーは「mail_user」としてuid「500」としていた。

#環境
Amazon Linux2

#問題
dovecotがインストールされているサーバーでtelnetをしてもログインできない。
passを入力すると「Internal error occurred」のエラーが出る。

[root@ip-10-0-10-50 ~]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
mail_user
-ERR Unknown command.
user mail_user
+OK
pass mail_user
-ERR [SYS/TEMP] Internal error occurred. Refer to server log for more information.
Connection closed by foreign host.

#調査
###systemctl status dovecotで確認
uid=500として設定した「mail_user」に権限がないと出力される。

[root@ip-10-0-10-50 ~]# systemctl status dovecot
● dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-10-25 10:55:04 UTC; 5 days ago
     Docs: man:dovecot(1)
           http://wiki2.dovecot.org/
  Process: 13854 ExecStop=/usr/bin/doveadm stop (code=exited, status=0/SUCCESS)
  Process: 13866 ExecStart=/usr/sbin/dovecot (code=exited, status=0/SUCCESS)
  Process: 13863 ExecStartPre=/usr/sbin/portrelease dovecot (code=exited, status=0/SUCCESS)
  Process: 13859 ExecStartPre=/usr/libexec/dovecot/prestartscript (code=exited, status=0/SUCCESS)
 Main PID: 13869 (dovecot)
   CGroup: /system.slice/dovecot.service
           ├─ 7624 dovecot/ssl-params
           ├─13869 /usr/sbin/dovecot
           ├─13871 dovecot/anvil
           ├─13872 dovecot/log
           └─13874 dovecot/config

Oct 30 18:27:24 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Disconnected (no auth attempts in 2 secs): user=<>, rip=209.17.97.90, lip=10...3REWFa>
Oct 30 18:48:36 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Disconnected (no auth attempts in 2 secs): user=<>, rip=66.228.34.83, lip=10...5C5CJT>
Oct 30 18:57:28 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=45.33.91.76, lip=10....4tIVtM>
Oct 30 20:47:48 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Disconnected (no auth attempts in 2 secs): user=<>, rip=50.116.49.185, lip=1...4ydDG5>
Oct 30 20:56:19 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=45.79.158.15, lip=10...4tT54P>
Oct 30 22:48:31 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Disconnected (no auth attempts in 3 secs): user=<>, rip=198.74.60.35, lip=10...7GSjwj>
Oct 30 22:55:57 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=45.79.186.125, lip=1...4tT7p9>
Oct 31 00:34:27 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3-login: Login: user=<mail_user>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=12...x/AAAB>
Oct 31 00:34:27 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3(mail_user): Error: Mail access for users with UID 500 not permitted (see first_vali...ookup).
Oct 31 00:34:27 ip-10-0-10-50.ap-northeast-1.compute.internal dovecot[13872]: pop3(mail_user): Error: Invalid user settings. Refer to server log for more information.
Hint: Some lines were ellipsized, use -l to show in full.

###「linux uid not permitted」でぐぐる
「/etc/dovecot/conf.d/10-mail.conf」ファイルに「first_valid_uid = 1000」と設定されているため
uid1000未満はログインできないとのこと。(要参考記事参照)

#原因
uidの設定値を1000以下にしていたためログインできなかった。

#解決策

「/etc/dovecot/conf.d/10-mail.conf」ファイルの「first_valid_uid = 1000」を「first_valid_uid = 500」と変更する。

#結果
telnetアクセスができ、メール受信がされていることが確認できた。

[root@ip-10-0-10-50 ~]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user mail_user
+OK
pass mail_user
+OK Logged in.
list
+OK 1 messages:
1 2777

#参考記事
https://teratail.com/questions/77095

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?