1、简介

Telnet协议是TCP/IP协议族中的一员,是Internet远程登陆服务的标准协议和主要方式。它为用户提供了在本地计算机上完成远程主机工作的能力。在终端使用者的电脑上使用telnet程序,用它连接到服务器。终端使用者可以在telnet程序中输入命令,这些命令会在服务器上运行,就像直接在服务器的控制台上输入一样。可以在本地就能控制服务器。要开始一个telnet会话,必须输入用户名和密码来登录服务器。Telnet是常用的远程控制Web服务器的方法。

2、安装

默认在centOS最小安装下没有安装telnet服务的,需要自己安装(****root权限****):

错误:

[root@localhost log]# telnet 192.168.10.56 27017
-bash: telnet: command not found

1:查看系统版本信息(centos7):

[root@localhost log]# cat /etc/issue
\S
Kernel \r on an \m

2:检查是否安装telnet:

[root@localhost log]# rpm -qa | grep telnet
[root@localhost log]#

3:进行安装,客户端和服务器端:

[root@localhost xinetd.d]# yum -y install telnet
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
……………………Verifying  : 1:telnet-0.17-59.el7.x86_64      1/1
Installed:telnet.x86_64 1:0.17-59.el7
Complete!
[root@localhost xinetd.d]# yum -y install telnet-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
……………………Verifying  : 1:telnet-server-0.17-59.el7.x86_64      1/1
Installed:telnet-server.x86_64 1:0.17-59.el7
Complete!

注:如果安装telnet-server服务启动依赖xinetd服务.xinetd超级服务为管理保护各个服务,未安装,需要首先按照。

xinetd:eXtended InterNET services daemon,超级Internet服务器,常用来管理多种轻量级Internet服务。

*4:查看是否安装xinetd (若安装则不安装):*

[root@localhost ~]# rpm -qa | grep xinetd
[root@localhost ~]#

*5:安装xinetd服务:*

[root@localhost init.d]# yum -y install xinetd
Loaded plugins: fastestmirror
base                                  | 3.6 kB  00:00:00
……………………Verifying  : 2:xinetd-2.3.15-12.el7.x86_64         1/1 Installed:xinetd.x86_64 2:2.3.15-12.el7                                                                                                                                                                Complete!

xinetd安装完成!****
6:telnet服务之后,默认是不开启服务,修改文件/etc/xinetd.d/telnet来开启服务:****
注:如有则修改,第一次修改,此文件若不存在,可自己vim创建修改:
修改 disable = yes 为 disable = no

[root@localhost xinetd.d]# pwd
/etc/xinetd.d
[root@localhost xinetd.d]# ls
chargen-dgram  chargen-stream  daytime-dgram  daytime-stream  discard-dgram  discard-stream  echo-dgram  echo-stream  tcpmux-server  time-dgram  time-stream[root@localhost xinetd.d]# vim telnet
[root@localhost xinetd.d]# cat telnet

修改后的telnet文件为:

# default: yes# description: The telnet server servestelnet sessions; it uses \#      unencrypted username/password pairs for authentication.
service telnet{flags           = REUSEsocket_type     = streamwait            = nouser            = rootserver          =/usr/sbin/in.telnetdlog_on_failure  += USERIDdisable         = no
}

*7:安装后检查:*

[root@CentOS-Slave1 xinetd.d]# rpm -qa | grep telnet
telnet-0.17-59.el7.x86_64
telnet-server-0.17-59.el7.x86_64
[root@CentOS-Slave1 xinetd.d]# rpm -qa | grep xinetd
xinetd-2.3.15-12.el7.x86_64

*8:启动telnet和依赖的xinetd服务:*

在centos7之前:

$ service  xinetd restart
或$ /etc/rc.d/init.d/xinetd  restart

在centos7中(无xinetd的service启动项):

[root@CentOS-Slave1 xinetd.d]# service xinetd restart
Redirecting to /bin/systemctl restart  xinetd.service
[root@CentOS-Slave1 xinetd.d]# systemctl restart  xinetd.service

[root@CentOS-Slave1 xinetd.d]# /bin/systemctl restart  xinetd.service

*9:查看启动:*

[root@CentOS-Slave1 xinetd.d]# ps -ef | grep xinetd
root      6641     1  0 23:22 ?        00:00:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
root      6644  5817  0 23:24 pts/3    00:00:00 grep --color=auto xinetd

10:测试telent,输入ip+用户名+密码登陆,登陆问题见备注附件:

[root@CentOS-Slave1 pam.d]# telnet 192.168.10.56
Trying 192.168.10.56...
Connected to 192.168.10.56.
Escape character is '^]'.Kernel 3.10.0-229.el7.x86_64 on an x86_64
CentOS-Slave1 login: root
Password:
Last failed login: Sat Oct 17 23:25:50 CST 2015 from CentOS-Slave1 on pts/0
There were 3 failed login attempts since the last successful login.
Last login: Sat Oct 17 22:22:27 from CentOS-Slave1
[root@CentOS-Slave1 ~]# exit
logout
Connection closed by foreign host.

*11:设置服务开机启动:*

[root@CentOS-Slave1 rc3.d]# chkconfig --level 35 xinetd on
Note: Forwarding request to 'systemctl enable xinetd.service'.
[root@CentOS-Slave1 rc3.d]# systemctl enable xinetd.service

*12:查看:*

[root@CentOS-Slave1 rc3.d]# chkconfig --listNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.mysql            0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:offxinetd based services:chargen-dgram:   offchargen-stream:  offdaytime-dgram:   offdaytime-stream:  offdiscard-dgram:   offdiscard-stream:  offecho-dgram:      offecho-stream:     offtcpmux-server:   offtelnet:          ontime-dgram:       offtime-stream:     off

备注附件:

*问题1:*

telnet下root登录,密码正确,总提示:Login incorrect
****解决1****:注释/etc/pam.d/remote的第一行,
即:auth required pam_securetty.so

[root@CentOS-Slave1 pam.d]# pwd
/etc/pam.d
[root@CentOS-Slave1 pam.d]# cat remote
#%PAM-1.0
#telent 远程root登陆允许
#auth       required     pam_securetty.so
auth       substack     password-auth
auth       include      postlogin
………………

问题2:其他机器远程telnet的时候,登陆不成功,可能是防火墙的问题,修改防火墙的设置:

注:netstat –tunlp查看是否23端口被防火墙封掉:

[root@CentOS-Slave1 pam.d]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      5891/./mongod
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      848/sshd
tcp6       0      0 :::3306                 :::*                    LISTEN      1997/mysqld
tcp6       0      0 :::22                   :::*                    LISTEN      848/sshd
tcp6       0      0 :::23                   :::*                    LISTEN      1/systemd

再使用iptables修改设置,使用service iptables save保存设置,然后service iptables restart重启防火墙:

iptables -I INPUT -p tcp --dport 23 -jACCEPT
iptables -I INPUT -p udp --dport 23 -jACCEPT
service iptables save  //保存
service iptables restart //重启防火墙

*问题new:*

[root@CentOS-Slave1 rc3.d]# chkconfig --level 35 xinetd on
Note: Forwarding request to ‘systemctl enable xinetd.service’.
[root@CentOS-Slave1 xinetd.d]# service xinetd restart
Redirecting to /bin/systemctl restart xinetd.service

*解决new:*

*指令可以用,但是新版本系统,指令被(重新定向Redirecting/转发Forwarding)到:
service xinetd restart —> systemctl restart xinetd.service*

*chkconfig --level 35 xinetd on —> systemctl enable sshd.service #对应为disable*

*$.记住:以后控制服务就用这个指令。*

疑问3:telnet登陆主机后会提示Escape character is ‘^]’:

点击提示的意思是按Ctrl + ] 会呼出telnet的命令行,就可以执行telnet命令:

*telnet命令:*

#close关闭当前连接
#logout强制退出远程用户并关闭连接
#display显示当前操作的参数
#mode试图进入命令行方式或字符方式
#open连接到某一站点
#quit退出
#telnetsend发送特殊字符
#set设置当前操作的参数
#unset复位当前操作参数
#status打印状态信息
#toggle对操作参数进行开关转换
#slc改变特殊字符的状态
#auth打开/关闭确认功能z挂起
#telnetenviron更改环境变量,显示帮助信息

*iptables参数:*

iptables [-AI 链名] [-io 网络接口] [-p 协议] \
> [-s 来源IP/网域] [-d 目标IP/网域] -j [ACCEPT|DROP|REJECT|LOG]
选项与参数:
-AI 链名:针对某的链进行规则的 "插入" 或 "累加"-A :新增加一条规则,该规则增加在原本规则的最后面。例如原本已经有四条规则,使用 -A 就可以加上第五条规则!-I :插入一条规则。如果没有指定此规则的顺序,默认是插入变成第一条规则。例如原本有四条规则,使用 -I 则该规则变成第一条,而原本四条变成 2~5 号链 :有 INPUT, OUTPUT, FORWARD 等,此链名称又与 -io 有关,请看底下。
-io 网络接口:设定封包进出的接口规范-i :封包所进入的那个网络接口,例如 eth0, lo 等接口。需与 INPUT 链配合;-o :封包所传出的那个网络接口,需与 OUTPUT 链配合;-p 协定:设定此规则适用于哪种封包格式,主要的封包格式有: tcp, udp, icmp 及 all 。-s 来源 IP/网域:设定此规则之封包的来源项目,可指定单纯的 IP 或包括网域,例如:IP  :192.168.0.100网域:192.168.0.0/24, 192.168.0.0/255.255.255.0 均可。若规范为『不许』时,则加上 ! 即可,例如:-s ! 192.168.100.0/24 表示不许 192.168.100.0/24 之封包来源;-d 目标 IP/网域:同 -s ,只不过这里指的是目标的 IP 或网域。-j :后面接动作,主要的动作有接受(ACCEPT)、丢弃(DROP)、拒绝(REJECT)及记录(LOG)

linux运行级别

chkconfig命令提供了一种简单的方式来设置一个服务的运行级别,on和off分别指服务被启动和停止。
运行级别就是操作系统当前正在运行的功能级别。级别是从0到6。
级别3和5上设定服务为“on”
chkconfig --level 35 mysql on
其他级别上设为off
chkconfig --level 01246 mysql off
列出服务将会运行的运行级别
#chkconfig --list mysql
mysql 0:off 1:off 2:off 3:on 4:off 5:on 6:offLinux下的7个运行级别:
0:系统停机状态,系统默认运行级别不能设置为0,否则不能正常启动,机器关闭。
1:单用户工作状态,root权限,用于系统维护,禁止远程登陆,就像Windows下的安全模式 登录。
2:多用户状态,没有NFS支持。
3:完整的多用户模式,有NFS,登陆后进入控制台命令行模式。
4:系统未使用,保留一般不用,在一些特殊情况下可以用它来做一些事情。eg:在笔记本电脑的电池用尽时,可以切换到这个模式来做一些设置。
5:X11控制台,登陆后进入图形GUI模式,XWindow系统。
6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动。运行init6机器就会重启。标准的Linux运行级别为3或5运行级别原理:
1.在目录/etc/rc.d/init.d下有许多服务器脚本程序,一般称为服务(service)
2.在/etc/rc.d下有7个名为rcN.d的目录(N:0,1,2……),对应系统的7个运行级别
3.rcN.d目录下都是一些符号链接文件,这些链接文件都指向init.d目录下的service脚 本文件,命名规则为K+nn+服务名或S+nn+服务名,其中nn为两位数字。
4.系统会根据指定的运行级别进入对应的rcN.d目录,并按照文件名顺序检索目录下的链接文件:对于以K(Kill)开头的文件,系统将终止对应的服;对于以S(Start开头的文件,系统将启动对应的服务
5.查看运行级别用:runlevel
[root@CentOS-Slave1 pam.d]# runlevelN 3
[root@CentOS-Slave1 etc]# cd rc.d/
[root@CentOS-Slave1 rc.d]# ls
init.d  rc0.d  rc1.d  rc2.d  rc3.d  rc4.d  rc5.d  rc6.d  rc.local
[root@CentOS-Slave1 rc.d]# cd rc3.d/
[root@CentOS-Slave1 rc3.d]# ls
K50netconsole  S10network  S64mysql
[root@CentOS-Slave1 rc3.d]# pwd
/etc/rc.d/rc3.d

telnet的安装与使用相关推荐

  1. 关于telnet的安装

    准确地说,网络通不通用ping,tcp端口能不能访问用telnet或nc,udp端口能不能访问用nc . 下面把telnet的安装做一个介绍: 1.先检查系统上是否安装了telnet,如下图代表已经安 ...

  2. FC6下的ftp服务和telnet服务安装

    费了几天的劲,终于把FC6下的ftp服务和telnet服务安装上了! 我是用的VMware 6下建的FC6, 1.启动ftp服务:,我是菜鸟,开始不知道FC6下带着ftp服务,于是疯狂的找rpm包,找 ...

  3. Telnet服务安装及配置

    安装Telnet服务: [root@Server ~]# yum install telnet-server -y Installing : 2:xinetd-2.3.14-40.el6.x86_64 ...

  4. Centos下telnet的安装和配置

    网上摘录的留着自己有用! 摘自:http://blog.sina.com.cn/s/blog_53ec9d910101pmi0.html#post vista或windows 7的系统默认安装是没有安 ...

  5. Telnet详情及Telnet的安装

    Telnet讲解 Telnet服务详解telnet协议是TCP/IP协议族中的一员,是Internet远程登陆服务的标准协议和主要方式.它为用户提供了在本地计算机上完成远程主机工作的能力.在终端使用者 ...

  6. Telnet命令安装+详解

    1.Telnet是什么 2.有什么用 3.可以用来干什么 1.telnet是什么 Telnet是teletype network的缩写,专业的说,Telnet是Internet上远程登录的一种程序:它 ...

  7. win7 Telnet功能安装

    找不到Telnet并不是Windows 7抛弃了Telnet,而是默认状态下Windows 7并没有安装Telnet服务. 这也是微软第一次从个人系统中将Telnet剔出了系统默认组件之外,这和Win ...

  8. centos7 telnet服务安装

      检查是否安装telnet rpm -qa | grep telnet  安装telnet yum -y install telnet yum -y install telnet-server  检 ...

  9. RedHat6.5-Linux安装telnet服务

    1 下载以下三个包 telnet-0.17-47.el6.x86_64.rpm(telnet客户端) telnet-server-0.17-47.el6.x86_64.rpm(telnet服务端) x ...

最新文章

  1. 熟悉常用的HDFS操作
  2. CTFshow 文件包含 web116
  3. 揭示垃圾收集暂停的时间长度
  4. 开源xen对比_女实习生在Xen Project上摇摆开源
  5. python识别pdf文字_Python 神工具包!翻译、文字识别、语音转文字统统搞定
  6. 【bzoj 3595】: [Scoi2014]方伯伯的Oj
  7. 使用模板实现asp代码和页面分离_asp技巧
  8. greenev —— Python 异步网络服务框架
  9. 题目 1842: 对局匹配
  10. 树莓派linux负载均衡集群,在树莓派2上Nginx并发1W到底有多难
  11. 关于awk 中如何使用 if条件判断句
  12. threejs生成由内而外光圈、城市掠过。
  13. csgo服务器搭建 linux,Centos 搭建 CSGO KZ 服务器
  14. win10怎么录制电脑屏幕 电脑录制视频
  15. J9数字平台科普:Web3支柱:去中心化存储全面解析
  16. 计算机开机卡在进入桌面的时候,电脑开机进不了系统 系统开机后停留在》》》》=======的界面...
  17. u9系统的使用方法仓库_晋江正版用友u9系统使用方法-好不好用
  18. PMP备考指南之第八章:项目质量管理
  19. 家庭媒体中心解决方案(一、简介)
  20. python卸载opencv包_Ubuntu下安装与卸载opencv模块

热门文章

  1. Wuss Weapp一款高质量,组件齐全,高自定义的微信小程序 UI 组件库
  2. 企业网络中一个非常诡异的部分网页打不开的问题
  3. 决策树分类器的应用研究——乳腺癌诊断
  4. sql server生日提醒语句实现方法
  5. RTC 系统音视频传输弱网对抗技术
  6. 静态全局变量和全局变量
  7. css小三角气泡效果,纯CSS实现聊天框小尖角、气泡效果
  8. 劳动合同法之试用期工资的算法(轉)
  9. LocalDate日期相差天数; 当前日期加一天或减一天
  10. 测试用例编写及用例评审方法