Telenetでリモートホストに接続する「telnet」コマンドの概要と使い方を記載しています。
RHEL Fedora CentOS Vine Deblan Ubuntu Plamo
参考サイト:Man page of INSTALL
概要・使用方法
書式
$ telnet [オプション] [ホスト名] [サービス]
Telnetプロトコルを使ってtelnetdが稼働しているリモートホストに接続します。telnetを利用してリモートホストと通信すると、ユーザ名やパスワード、通信内容が暗号化されていない「平文」で流れてしまい、途中経路で盗聴される可能性があります。リモートアクセスはtelnetの代替ツールであるsshを利用します。telnetはリモートログインの用途よりも、リモートホストとポート番号(http(80)やsmtp(25)など)を指定してサーバのデバックなどでよく利用されます。また、pingコマンドはICMPプロトコルをセキュリティ上拒否しているケースがあるので、pingコマンドの代わりにサーバーの稼働状況やサービスの稼働状況を確認にもよく利用されます。
telnetコマンドは標準でインストールされていないことがあるので、「yum install telnet」でインストールする必要があります。
オプション
| -e 文字 | エスケープ文字を指定した文字にする |
| -E | エスケープ文字機能を無視する |
| -l ユーザ名 | ログインユーザを指定する |
Telnetプロトコルでリモートホストに接続する
$ telnet ホスト名
実行結果
[root@centos ~]# telnet kcfran.com
Trying 153.122.22.98...
TelnetでHTTPサーバにアクセスする
$ telnet ホスト名 ポート番号
実行結果
[root@centos ~]# telnet kcfran.com 443
Trying 153.122.22.98...
Connected to kcfran.com.
Escape character is '^]'.
GET / HTTP/1.0
HTTP/1.1 400 Bad Request
Date: Thu, 22 Dec 2022 00:05:09 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.14
Content-Length: 362
Connection: close
Content-Type: text/html; charset=iso-8859-1
400 Bad Request
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
Connection closed by foreign host.
[root@centos ~]#
Telnetでメールを送信
実行結果
$ telnet mail.example.com 25 #.
hello!!
. #本文終了は「.」で知らせる
250 ok: queued as 0E8F975C017
quit #<終了
221 Bye
Connection closed by foreign host.
