メインコンテンツへスキップ
  1. Linux 関連記事一覧/
  2. Ubuntu 26.04 LTS Server/

Ubuntu 26.04 LTS Server の telnet サーバー設定

目次

telnet サーバーを使う前に

telnet は利用者名・パスワード・操作内容をすべて暗号化せずに送ります。 インターネットに面したサーバーでは使わないでください。リモートログインには通常 SSH サーバーを使います。

使いどころは、閉じた検証環境や、telnet しか話せない機器の相手をするときに限られます。この記事では設定手順に加えて、パスワードが実際にそのまま読めることをパケットキャプチャーで確かめます。

編集するファイル用途
/etc/inetd.conftelnet の行(有効・無効の切り替え)
/etc/hosts.deny接続元の制限

導入状況を確認する

クライアントは最初から入っていますが、サーバーは入っていません。

サーバー側(sv1)の確認 実行例
kazulog@sv1:~$ apt list --installed 2>/dev/null | grep -E "telnet|inetd" | cat
inetutils-telnet/resolute-updates,resolute-security,now 2:2.7-2ubuntu1.1 amd64 [installed,automatic]
telnet/resolute-updates,resolute-security,now 0.17+2.7-2ubuntu1.1 all [installed,automatic]
kazulog@sv1:~$ apt-cache policy inetutils-telnetd | head -3
inetutils-telnetd:
  Installed: (none)
  Candidate: 2:2.7-2ubuntu1.1
クライアント側(sv2)の確認 実行例
kazulog@sv2:~$ which telnet ssh
/usr/bin/telnet
/usr/bin/ssh
パッケージ役割
inetutils-telnetクライアント(telnet コマンド)。既定で入っている
inetutils-telnetdサーバー。telnetd という名前のパッケージはこれを入れるためのダミー

telnet サーバーを導入する

導入コマンド
sudo apt install -y inetutils-telnetd

telnet サーバーは単独では待ち受けず、スーパーサーバーの inetutils-inetd が接続を受けて起動します。そのため一緒に入ります。仕組みはinetd(スーパーサーバー)設定で解説しています。

導入 実行例
kazulog@sv1:~$ sudo apt install -y inetutils-telnetd | cat
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Solving dependencies...
Installing:
  inetutils-telnetd

Installing dependencies:
  inetutils-inetd  tcpd  update-inetd

Summary:
  Upgrading: 0, Installing: 4, Removing: 0, Not Upgrading: 96
  Download size: 153 kB
  Space needed: 546 kB / 63.1 GB available

Get:1 http://archive.ubuntu.com/ubuntu resolute/universe amd64 tcpd amd64 7.6.q-36build2 [24.6 kB]
Get:2 http://archive.ubuntu.com/ubuntu resolute/main amd64 update-inetd all 4.54build1 [23.0 kB]
Get:3 http://archive.ubuntu.com/ubuntu resolute-updates/universe amd64 inetutils-inetd amd64 2:2.7-2ubuntu1.1 [45.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu resolute-updates/universe amd64 inetutils-telnetd amd64 2:2.7-2ubuntu1.1 [60.6 kB]
Preconfiguring packages ...
Fetched 153 kB in 2s (85.3 kB/s)
Selecting previously unselected package tcpd.
(Reading database ... 91400 files and directories currently installed.)
Preparing to unpack .../tcpd_7.6.q-36build2_amd64.deb ...
Unpacking tcpd (7.6.q-36build2) ...
Selecting previously unselected package update-inetd.
Preparing to unpack .../update-inetd_4.54build1_all.deb ...
Unpacking update-inetd (4.54build1) ...
Selecting previously unselected package inetutils-inetd.
Preparing to unpack .../inetutils-inetd_2%3a2.7-2ubuntu1.1_amd64.deb ...
Unpacking inetutils-inetd (2:2.7-2ubuntu1.1) ...
Selecting previously unselected package inetutils-telnetd.
Preparing to unpack .../inetutils-telnetd_2%3a2.7-2ubuntu1.1_amd64.deb ...
Unpacking inetutils-telnetd (2:2.7-2ubuntu1.1) ...
Setting up update-inetd (4.54build1) ...
Setting up tcpd (7.6.q-36build2) ...
Setting up inetutils-inetd (2:2.7-2ubuntu1.1) ...
Created symlink '/etc/systemd/system/inetd.service''/usr/lib/systemd/system/inetutils-inetd.service'.
Created symlink '/etc/systemd/system/multi-user.target.wants/inetutils-inetd.service''/usr/lib/systemd/system/inetutils-inetd.service'.
Setting up inetutils-telnetd (2:2.7-2ubuntu1.1) ...

入れただけでは使えません。 /etc/inetd.conf23行目に telnet の行ができますが、行頭が #<off># の無効な状態です。有効な行が無いので inetd も起動を見送り、23番は開きません。

導入直後の /etc/inetd.conf と inetd の状態 実行例
kazulog@sv1:~$ grep -n telnet /etc/inetd.conf
23:#<off># telnet	stream	tcp	nowait	root	/usr/sbin/tcpd	/usr/sbin/telnetd
kazulog@sv1:~$ systemctl status inetutils-inetd --no-pager | head -9 | cat
○ inetutils-inetd.service - GNU Network Utilities internet superserver
     Loaded: loaded (/usr/lib/systemd/system/inetutils-inetd.service; enabled; preset: enabled)
     Active: inactive (dead) (Result: exec-condition) since Sat 2026-09-12 09:08:41 JST; 7s ago
 Invocation: 5197dfcb6b574992b9abab5f7049d3a7
  Condition: start condition unmet at Sat 2026-09-12 09:08:41 JST; 7s ago
       Docs: man:inetutils-inetd(8)
             https://www.gnu.org/software/inetutils/manual/
    Process: 2629 ExecCondition=grep -qr ^[0-9A-Za-z/] /etc/inetd.conf /etc/inetd.d/ (code=exited, status=1/FAILURE)
   Mem peak: 1.7M
kazulog@sv1:~$ sudo ss -tlnp 'sport = :23'; echo "ss rc=$?"
State                  Recv-Q                  Send-Q                                   Local Address:Port                                   Peer Address:Port                 Process
ss rc=0

telnet を有効にする(/etc/inetd.conf)

/etc/inetd.conf の 23行目から、行頭の #<off># を外します。この行の書き換えには専用のコマンド update-inetd を使います(直接編集しても構いませんが、update-inetd は inetd の再読み込みまで行います)。

有効にするコマンド
sudo update-inetd --enable telnet
/etc/inetd.conf の 23行目(変更後)
telnet	stream	tcp	nowait	root	/usr/sbin/tcpd	/usr/sbin/telnetd

有効な行ができると inetd が起動し、23番を待ち受けます。行のプロトコル欄が tcp なので、IPv4 だけで待ち受けます。

有効化 実行例
kazulog@sv1:~$ sudo update-inetd --enable telnet
kazulog@sv1:~$ grep -n telnet /etc/inetd.conf
23:telnet	stream	tcp	nowait	root	/usr/sbin/tcpd	/usr/sbin/telnetd
kazulog@sv1:~$ systemctl is-active inetutils-inetd
active
kazulog@sv1:~$ sudo ss -tlnp 'sport = :23'
State              Recv-Q             Send-Q                          Local Address:Port                           Peer Address:Port             Process
LISTEN             0                  10                                    0.0.0.0:23                                  0.0.0.0:*                 users:(("inetutils-inetd",pid=3120,fd=4))             

接続する

検証用の利用者を作ります。このパスワードは平文で流れることを示すための検証専用の文字列で、実際の運用では使いません。

検証用の利用者を作る 実行例
kazulog@sv1:~$ sudo useradd -m -s /bin/bash telnetdemo
kazulog@sv1:~$ echo 'telnetdemo:TelnetIsPlaintext' | sudo chpasswd
kazulog@sv1:~$ id telnetdemo
uid=1001(telnetdemo) gid=1001(telnetdemo) groups=1001(telnetdemo)

別のサーバーから接続し、ログインして w を実行します。

telnet でログイン 実行例
kazulog@sv2:~$ telnet 192.168.100.10
Trying 192.168.100.10...
Connected to 192.168.100.10.
Escape character is '^]'.

Linux 7.0.0-30-generic (ubuntu) (pts/0)

sv1 login: telnetdemo
Password: 
Welcome to Ubuntu 26.04 LTS (GNU/Linux 7.0.0-30-generic x86_64)

 * Documentation:  https://docs.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Sat Sep 12 09:09:13 JST 2026

  System load:  0.4               Processes:             108
  Usage of /:   3.5% of 60.93GB   Users logged in:       0
  Memory usage: 12%               IPv4 address for ens2: 10.19.12.11
  Swap usage:   0%


Expanded Security Maintenance for Applications is not enabled.

101 updates can be applied immediately.
91 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status



The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

telnetdemo@sv1:~$ w
 09:09:14 up 7 min,  1 user,  load average: 0.40, 0.25, 0.14
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU  WHAT
telnetde pts/0    192.168.100.20   09:09    1.00s  0.04s   ?    w
telnetdemo@sv1:~$ exit
logout
Connection closed by foreign host.

パスワードが平文で流れることを確かめる

sv1 とスイッチの間のリンクでキャプチャーしながら、上のログインを行いました。クライアントが送ったデータを取り出すと、入力した文字がそのまま並びます。

クライアントが送ったデータ 実行例
$ tshark -r ubuntu-telnet.pcap -n -Y 'ip.src==192.168.100.20 && telnet.data' -T fields -e frame.number -e telnet.data
22	telnetdemo\r
27	TelnetIsPlaintext\r
40	w\r
45	exit\r

利用者名(No.22)、パスワード(No.27)、コマンド(No.40 の w、No.45 の exit)がすべて読めます。パスワードのパケットを16進で見ても、文字列がそのまま入っています。

No.27 の中身 実行例
$ tshark -r ubuntu-telnet-no27.pcap -n -x
0000  52 54 00 9b cb ec 52 54 00 3b a6 5b 08 00 45 00   RT....RT.;.[..E.
0010  00 46 39 44 40 00 40 06 b7 fe c0 a8 64 14 c0 a8   .F9D@.@.....d...
0020  64 0a 8a e4 00 17 8d 63 fa f2 92 5d 74 f7 80 18   d......c...]t...
0030  00 fb 8d 50 00 00 01 01 08 0a 33 01 40 c2 2e be   ...P......3.@...
0040  78 34 54 65 6c 6e 65 74 49 73 50 6c 61 69 6e 74   x4TelnetIsPlaint
0050  65 78 74 0d                                       ext.
上のtshark出力のパケット(No.27)のpcapをダウンロード

SSH と比べる

同じ利用者で、SSH のパスワード認証を使って同じ操作をします。

SSH でログイン 実行例
kazulog@sv2:~$ ssh -o PubkeyAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null telnetdemo@192.168.100.10
Warning: Permanently added '192.168.100.10' (ED25519) to the list of known hosts.
telnetdemo@192.168.100.10's password:
Welcome to Ubuntu 26.04 LTS (GNU/Linux 7.0.0-30-generic x86_64)

 * Documentation:  https://docs.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Sat Sep 12 09:11:17 JST 2026

  System load:  0.13              Processes:             109
  Usage of /:   3.5% of 60.93GB   Users logged in:       0
  Memory usage: 12%               IPv4 address for ens2: 10.19.12.11
  Swap usage:   0%


Expanded Security Maintenance for Applications is not enabled.

101 updates can be applied immediately.
91 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


telnetdemo@sv1:~$ w
 09:11:17 up 9 min,  1 user,  load average: 0.13, 0.18, 0.12
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU  WHAT
telnetde pts/0    192.168.100.20   09:11    0.00s  0.05s   ?    w
telnetdemo@sv1:~$ exit
logout
Connection to 192.168.100.10 closed.

同じキャプチャーの中で、パスワードの文字列を含む SSH のパケットは1つもありません。

SSH にパスワードが出ないこと 実行例
$ tshark -r ubuntu-telnet.pcap -n -Y 'tcp.port==22 && frame contains "TelnetIsPlaintext"' | wc -l
       0

平文で読めるのは、最初に交換するバージョン文字列だけです。

SSH のバージョン文字列 実行例
$ tshark -r ubuntu-telnet.pcap -n -Y 'ssh.protocol' -T fields -e frame.number -e ip.src -e ssh.protocol
62	192.168.100.20	SSH-2.0-OpenSSH_10.2p1 Ubuntu-2ubuntu3.5
64	192.168.100.10	SSH-2.0-OpenSSH_10.2p1 Ubuntu-2ubuntu3.5

クライアントが送った暗号化パケットを16進で見ても、読める文字列はありません。

暗号化パケットの中身 実行例
$ tshark -r ubuntu-telnet-no74.pcap -n -x
0000  52 54 00 9b cb ec 52 54 00 3b a6 5b 08 00 45 b8   RT....RT.;.[..E.
0010  00 88 97 ae 40 00 40 06 58 9a c0 a8 64 14 c0 a8   ....@.@.X...d...
0020  64 0a 80 bc 00 16 50 bf 95 d5 93 3b 05 b2 80 18   d.....P....;....
0030  01 01 94 85 00 00 01 01 08 0a 53 3a 79 f6 5c c6   ..........S:y.\.
0040  25 61 00 00 00 0c 0a 15 00 00 00 00 00 00 00 00   %a..............
0050  00 00 01 28 41 dc e0 7e 4d fe c6 7e 1a e2 a3 3a   ...(A..~M..~...:
0060  d0 52 39 09 3e af 3c 1f 14 8e d1 bd 1c 2d 65 e4   .R9.>.<......-e.
0070  1f 90 c9 75 3f f2 fb b7 cc 2e 36 04 61 b9 37 6e   ...u?.....6.a.7n
0080  45 25 45 53 ed 1c e9 76 9b 09 5f 15 90 ea 48 72   E%ES...v.._...Hr
0090  85 22 04 a7 dc 9b                                 ."....
上のtshark出力のパケット(No.74)のpcapをダウンロード
項目telnetSSH
利用者名・パスワード平文で読める暗号化されて読めない
入力したコマンド平文で読める暗号化されて読めない
平文で読めるものすべて最初のバージョン文字列のみ

接続元を制限する(/etc/hosts.deny)

登録された行は /usr/sbin/tcpd を経由するので、/etc/hosts.deny で接続元を拒否できます。デーモン名は telnetd です。

編集するファイル
sudo vi /etc/hosts.deny
/etc/hosts.deny の末尾に追記
telnetd: 192.168.100.20
変更後の /etc/hosts.deny 実行例
kazulog@sv1:~$ cat /etc/hosts.deny
# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.
#
# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID
telnetd: 192.168.100.20

telnetd だけを指定しているので、SSH など他のサービスには影響しません。拒否された側は、接続した直後に切断されます。

拒否された側 実行例
kazulog@sv2:~$ timeout 8 telnet 192.168.100.10 < /dev/null
Trying 192.168.100.10...
Connected to 192.168.100.10.
Escape character is '^]'.
Connection closed by foreign host.
拒否のログ 実行例
kazulog@sv1:~$ sudo journalctl --since "-5 min" --no-pager | grep "refused connect" | cat
Sep 12 09:14:42 sv1 telnetd[4642]: refused connect from 192.168.100.20 (192.168.100.20)

hosts.allowhosts.deny の評価順や、ALL: ALL を書くときの注意はinetd の記事で解説しています。

設定ファイルの最終状態

ここまでの設定が入った状態です。触ったファイルは /etc/inetd.conf/etc/hosts.deny の2つだけです。

設定ファイルとサービスの状態
kazulog@sv1:~$ grep -n telnet /etc/inetd.conf
23:telnet	stream	tcp	nowait	root	/usr/sbin/tcpd	/usr/sbin/telnetd
kazulog@sv1:~$ cat /etc/hosts.deny
# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.
#
# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID
telnetd: 192.168.100.20
kazulog@sv1:~$ systemctl is-enabled inetutils-inetd; systemctl is-active inetutils-inetd
enabled
active
kazulog@sv1:~$ sudo ss -tlnp 'sport = :23'
State              Recv-Q             Send-Q                          Local Address:Port                           Peer Address:Port             Process
LISTEN             0                  10                                    0.0.0.0:23                                  0.0.0.0:*                 users:(("inetutils-inetd",pid=3120,fd=4))             
kazulog@sv1:~$ dpkg -l | grep -E "inetutils|tcpd|update-inetd" | cat
ii  inetutils-inetd                         2:2.7-2ubuntu1.1                           amd64        internet super server
ii  inetutils-telnet                        2:2.7-2ubuntu1.1                           amd64        telnet client
ii  inetutils-telnetd                       2:2.7-2ubuntu1.1                           amd64        telnet server
ii  tcpd                                    7.6.q-36build2                             amd64        Wietse Venema's TCP wrapper utilities
ii  tcpdump                                 4.99.6-1                                   amd64        command-line network traffic analyzer
ii  telnet                                  0.17+2.7-2ubuntu1.1                        all          transitional dummy package for inetutils-telnet default switch
ii  update-inetd                            4.54build1                                 all          inetd configuration file updater
ファイル変更内容
/etc/inetd.conf23行目の #<off># を外す(update-inetd --enable telnet
/etc/hosts.deny末尾に telnetd: 192.168.100.20 を追記
パッケージinetutils-telnetd と、依存で入る inetutils-inetd / tcpd / update-inetd

止める・削除する

一時的に止めるときは、行を無効に戻します。23行目に #<off># が戻り、23番が閉じます。

無効にするコマンド
sudo update-inetd --disable telnet

削除すると /etc/inetd.conf の telnet の行も消えます。一緒に入ったパッケージは autoremove で消えますが、inetutils-inetdupdate-inetd は設定ファイルが残る rc の状態になり、/etc/inetd.conf も残ります。

無効化と削除 実行例
kazulog@sv1:~$ sudo update-inetd --disable telnet
kazulog@sv1:~$ grep -n telnet /etc/inetd.conf
23:#<off># telnet	stream	tcp	nowait	root	/usr/sbin/tcpd	/usr/sbin/telnetd
kazulog@sv1:~$ sudo ss -tlnp 'sport = :23'; echo "ss rc=$?"
State                  Recv-Q                  Send-Q                                   Local Address:Port                                   Peer Address:Port                 Process
ss rc=0
kazulog@sv1:~$ sudo apt purge -y inetutils-telnetd | cat
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Solving dependencies...
The following packages were automatically installed and are no longer required:
  inetutils-inetd  tcpd  update-inetd
Use 'sudo apt autoremove' to remove them.

REMOVING:
  inetutils-telnetd*

Summary:
  Upgrading: 0, Installing: 0, Removing: 1, Not Upgrading: 96
  Freed space: 184 kB

(Reading database ... 91438 files and directories currently installed.)
Removing inetutils-telnetd (2:2.7-2ubuntu1.1) ...
Processing triggers for man-db (2.13.1-1build1) ...
(Reading database ... 91429 files and directories currently installed.)
Purging configuration files for inetutils-telnetd (2:2.7-2ubuntu1.1) ...
kazulog@sv1:~$ sudo apt autoremove -y | cat
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Solving dependencies...
REMOVING:
  inetutils-inetd  tcpd  update-inetd

Summary:
  Upgrading: 0, Installing: 0, Removing: 3, Not Upgrading: 96
  Freed space: 361 kB

(Reading database ... 91429 files and directories currently installed.)
Removing inetutils-inetd (2:2.7-2ubuntu1.1) ...
Removing tcpd (7.6.q-36build2) ...
Removing update-inetd (4.54build1) ...
Processing triggers for man-db (2.13.1-1build1) ...
kazulog@sv1:~$ dpkg -l | grep -E "inetd|telnet|tcpd" | cat
rc  inetutils-inetd                         2:2.7-2ubuntu1.1                           amd64        internet super server
ii  inetutils-telnet                        2:2.7-2ubuntu1.1                           amd64        telnet client
ii  tcpdump                                 4.99.6-1                                   amd64        command-line network traffic analyzer
ii  telnet                                  0.17+2.7-2ubuntu1.1                        all          transitional dummy package for inetutils-telnet default switch
rc  update-inetd                            4.54build1                                 all          inetd configuration file updater
kazulog@sv1:~$ ls -l /etc/inetd.conf 2>&1
-rw-r--r-- 1 root root 1062 Sep 12 09:15 /etc/inetd.conf

検証環境と実行ログ

CML 上に Ubuntu 26.04 LTS Server 2台を置いて採取しました。ディスクを wipe した直後の状態から始めています(前の検証で入れたパッケージが残っていると手順が再現しないため)。

検証構成
  sv1                             sv2
  ens3 192.168.100.10/24          ens3 192.168.100.20/24
  inetutils-telnetd (23/tcp)      telnet / ssh
   |                               |
   +----------- LAB-SW ------------+
   ^ このリンクでキャプチャー(23番と22番)

キャプチャー全体のファイルです。telnet と SSH のログインが同じファイルに入っています。

telnet と SSH のキャプチャー(ubuntu-telnet.pcap)
手順sv1sv2
初期状態(wipe 直後)show / conf / logshow / conf / log
inetutils-telnetd の導入show / conf / log
telnet の有効化show / conf / log
検証用利用者の作成show / conf / log
telnet ログインtelnet
SSH ログインssh
キャプチャーの解析tshark
接続元の拒否show / conf / log
拒否の確認show / conf / logshow / conf / log
設定ファイルの最終状態show / conf / log
無効化と削除show / conf / log

参考リンク

GNU Inetutils manual

関連記事

Ubuntu 公式ページ