1. 安装Telnet 客户端
$sudo apt-get install telnet
2. 安装Telnet 服务器(这样才能用A电脑的客户端连接B电脑的Telnet服务)
$ sudo apt-get install telnetd
3. 这时候Telnet服务器是无法自我启动的,需要网络守护进程服务程序来管理它。
$ sudo apt-get install xinetd 安装 xinetd
4. 修改配置文件
$sudo vim /etc/inetd.conf
添加:
telnet stream tcp nowait telnetd /usr/sbin/tcpd/ /usr/sbin/in.telnetd
telnet stream tcp nowait root /usr/sbin/tcpd/ /usr/sbin/in.telnetd
$sudo vim /etc/xinetd.conf
添加或修改:
# Simple configuration file for xinetd # # Some defaults, and include /etc/xinetd.d/ defaults { # Please note that you need a log_type line to be able to use log_on_success # and log_on_failure. The default is the following : # log_type = SYSLOG daemon info(插入红色部分) instances = 60 log_type = SYSLOG authpriv log_on_success = HOST PID log_on_failure = HOST cps = 25 30 } includedir /etc/xinetd.d
$ sudo vim /etc/xinetd.d/telnet
添加或修改:
# default: on # description: The telnet server serves telnet sessions; it uses # unencrypted username/password pairs for authentication. service telnet { disable = no flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd #in.telnetd是telnetd安装文件 log_on_failure += USERID }
5. 开启服务
$ sudo /etc/init.d/xinetd restart 重启服务
$ netstat -a | grep telnet 查看服务,显示服务器正在监听
$ telnet localhost 尝试连接本机,输入用户名、密码后连接成功
$netstat -a | grep telnet 可以看到已连接到本机服务,客户端与服务器可以进行数据传输
$ logout 退出登陆