2023年7月6日发(作者:)
telnet问题总结及参考汇总1). mount -n -t devpts devpts /dev/pts提⽰No such device.原因分析:内核配置中如果UNIX98_PTYS [=n]则会提⽰此错误。修改:
| : DEVPTS_MULTIPLE_INSTANCES [=y] |
| Prompt: Support multiple instances of devpts
|
| Defined at drivers/char/Kconfig:459 |
| Depends on: UNIX98_PTYS [=y] |
| Location: |
| -> Device Drivers |
| -> Character devices |
| -> Unix98 PTY support (UNIX98_PTYS [=y])
2). 可以使⽤mount命令查看devpts是否正确mount.3).# telnet 127.0.0.1 Entering character mode Escape character is '^]'. Connection closed by foreign host原因:可能是由上⼀个问题引起的。4).确认telnetd程序正确启动,可以使⽤ps命令查看。
参考⽂档:附件1:Escape character is '^]'. Connection closed by foreign 192.168.2.51Trying 192.168.Connected to character is '^]'.Connection closed by foreign host.⽤busybox做的ramdisk,内核编译启动后,telnet连接板⼦总是失败,后来找到了原因,原来需要 mknod⼀下⽂件节点,在dev下建⽴pts⽂件夹,在/etc/init.d/rcS⾥⾯加⼀句mount n /dev/pts -t devptsmknod -m 666 /dev/ptmx c 5 2就⾏了。附开启telnetd的过程:第⼀种⽅式:通过inetd启动telnetd服务必须这样设置busybox配置 Networking Utilities ---> 去掉 [ ] Support standalone telnetd (not inetd only)配置/etc/ [root@RITA ~]# vi /etc/ telnet stream tcp nowait root /usr/sbin/telnetd telnetd运⾏命令:/usr/sbin/inetd第⼆种⽅式:直接运⾏telnetd,启动服务必须这样设置busybox配置: Networking Utilities ---> 选择 [*] Support standalone telnetd (not inetd only)运⾏命令: /usr/sbin/telnetd可能出现的问题1)客户端登录不上,查看/var/log/message,得到如下信息:cat /var/log/messageNov 18 10:04:11 RITA telnetd[1442]: bind: Address already in use解决⽅法:修改busybox的配置Networking Utilities ---> 去掉 [ ] Support standalone telnetd (not inetd only)cat /var/log/message2)如果出现如下信息Nov 18 11:48:50 RITA telnetd[1782]: can't find free pty解决⽅法⼀:修改busybox配置 Busybox Settings ---> General Configuration ---> 去掉[ ] Use the devpts filesystem for Unix98 PTYs解决⽅法⼆: mkdir /dev/pts mount -t devpts devpts /dev/pts //将devpts⽂件系统加载在/dev/pst mknod -m 666 /dev/ptmx c 5 2 //使⽤telnetd所必须的设备⽂件节点
修改/etc/securetty,增加如下⾏: # psudo terminals used by telnet pts/0 pts/1 pts/2 pts/3 pts/4 pts/5 pts/6 pts/7经过上述修改后, 客户端应该可以telnet到板⼦上,信息如下:在192.168.0.1上运⾏telnet:(板⼦ip:192.168.0.100)在客户端运⾏命令:telnet 192.168.0.100 即出现如下登录提⽰信息: Welcome to RITA! RITAlogin: root Password:
[root@RITA ~]#我的/etc/init.d/rcS内容为:#! /bin/ash
ifconfig lo 127.0.0.1 mount none /proc -t proc mount none /sys -t sysfs ifconfig eth0 192.168.2.51 netmask 255.252.0.0mount n /dev/pts -t devpts mknod -m 666 /dev/ptmx c 5 2 #For telnetd telnetd export PS1="Godson2@w>"export PATH=/mnt/bin:$PATH
附件2:telnet协议是登陆远程⽹络主机最简单的⽅法之⼀,只是安全性⾮常低。对target board来说,必须执⾏telnet监控程序,这样才可以远程登陆到target board。同时,如果想从开发板通过telnet远程登陆其他host,就需要具备telent client。 在嵌⼊式Linux系统上的telnet的⼯具有: ·telnet client busybox telnet client。busybox本⾝就是为嵌⼊式系统量⾝打造,其telnet client精简,⽽且⽐较好⽤。 ·telnet server 主要有telnetd和utelnetd。就⽂件⼤⼩⽽⾔,utelnetd套件产⽣的⼆进制⽂件⽐telnetd要⼩,但是utelnetd不⽀持 internetsuper-server.下⾯先看busybox的telnet功能。client很简单,选择上就可以⽤了;⽽telnetd则要相对⿇烦⼀些。 Telnetd的移植倒不⿇烦,busybox已经集成了⼀个。但是因为开始时配置出现问题,所以费了些时间才算稳定。(1)busybox的配置 对Telnetd的配置部分:Networking Utilities --->
[*]telnetd[*] Support standalone telnetd (not inetd only)
这个地⽅的配置说明,telnetd可以由inetd来启动,也可以standalone启动。配置内核UNIX98_PTYS=y在/etc/init.d/rcS中加⼊mkdir /dev/ptsmount -t devpts devpts /dev/pts红⾊部分也可以在/etc/fstab中添加devpts /dev/pts devpts defaults 0 0⼿动添加⾸先我们介绍⼀下如何⼿动添加。以增加root⽤户为例,增加passwd⽂件,其内容为:#cat passwdroot:x:0:0:root:/root:/bin/sh同时,此时要确定root⽬录已经存在。passwd⼀共由7个字段组成,6个冒号将其隔开。它们的含义分别为:1 ⽤户名2 是否有加密⼝令,x表⽰有,不填表⽰⽆,采⽤MD5、DES加密。3 ⽤户ID4 组ID5 注释字段6 登录⽬录7 所使⽤的shell程序 增加group⽂件,其内容为:#cat grouproot:x:0:Group⼀共由4个字段组成,3个冒号将其隔开,它们的含义分别为:1 组名2 是否有加密⼝令,同 passwd3 组ID4 指向各⽤户名指针的数组
由于busybox默认启动了shadow模式,因此需要增加shadow⽂件,其内容为:#cat shadowroot:$1$3jZ93Mwq$oaeef6lWIuThavs8wD0Wh1:0:0:99999:7:::shadow⼀共由9个字段组成,8个冒号将其隔开,它们的含义分别为:1 ⽤户名2 加密后的⼝令,若为空,表⽰该⽤户不需要⼝令即可登陆,若为*号,表⽰该账号被禁⽤。 上⾯的表⽰的是123456加密后的⼝令。3 从1970年1⽉1⽇⾄⼝令最近⼀次被修改的天数4 ⼝令在多少天内不能被⽤户修改5 ⼝令在多少天后必须被修改(0 为没有修改过)6 ⼝令过期多少天后⽤户账号被禁⽌7 ⼝令在到期多少天内给⽤户发出警告8 ⼝令⾃1970年1⽉1⽇被禁⽌的天数9 保留域这⾥强调⼀下shadow⽂件的由来。/etc/passwd⽂件对系统的所有⽤户都是可读的,这样的好处是每个⽤户都知道系统上有哪些⽤户,但缺点是其他⽤户的⼝令容易受到攻击,尤其是当⼝令较简单时。所以⼀些linux系统中使⽤到了影⼦⼝令⽂件shadow,将⽤户的⼝令存储在另⼀个⽂件/etc/shadow中,该⽂件只有根⽤户root可读,⼤⼤提⾼了安全性。不过,采⽤这种⼿动添加⽂件的⽅法有⼀个缺陷,就是如果要为⽤户设置登陆⼝令的话,shadow⽂件中必须填写加密后的⼝令,⽽这个加密算法我们⼜不知道,即使知道,要经过转换后再添加,⽐较⿇烦。此时,不妨试⼀下第⼆种⽅法。⾃动添加⾃动⽣成是使⽤了busybox提供的adduser⼯具和passwd⼯具。在⽂件系统正常运⾏起来后,使⽤adduser命令,使⽤⽅法为:#adduser root然后就会在etc⽬录下⾃动⽣成passwd 、group和shadow3个⽂件。但是运⾏该命令后会打印出如下消息:passwd:unknown uid 0这表⽰不能为该⽤户设置密码,此时你会发现要passwd命令也⽆法使⽤。解决的办法是,打开passwd⽂件,其内容为:root:x:1000:1000:Linux User…:/home/root:/bin/sh将⽤户ID和组ID均更改为0打开group⽂件,其内容为:root:x:1000:同样将组ID改为0然后,passwd命令就可以正常使⽤了。这时为root⽤户设置⼝令:#passwd root根据提⽰输⼊密码。其中,root⽤户登陆后的⽬录可以⼿动进⾏更改。在rcS⽂件中添加如下脚本,启动telnetdif [ -x /usr/sbin/telnetd ] ;then telnetd&fiØ
在/dev⽬录下增加 null设备⽂件,否则上述脚本运⾏时会出错:提⽰找不到null⽂件。#mknod null c 1 3此时,telnetd功能开机就可以启动了。参考⽹址/?uid=48851&do=blog&id=11401/bbs/archiver/?执⾏telnet命令时,连接到远端机后使⽤“escape”字符可进⼊telnet命令模式,此模式下⽤户可以输⼊telnet能够解释的命令,来控制telnet或设定与telnet相关的参数。默认的“escape” 字符为“Ctrl+]”。⽤户可以使⽤set命令修改“escape”字符的默认值。
附件3:Telnet协议是登陆远程⽹络主机最简单的⽅法之⼀,只是安全性⾮常低。对target board来说,必须执⾏ telnet监控程序,这样才可以远程登陆到target board。同时,如果想从 开发板通过 telnet远程登陆其他host,就需要具备telent client。 在 嵌⼊式Linux系统上的telnet的⼯具有: · telnet client busybox telnet client。busybox本⾝就是为 嵌⼊式系统量⾝打造,其 telnet client精简,⽽且⽐较好⽤。 · telnet server 主要有telnetd和utelnetd。就⽂件⼤⼩⽽⾔,utelnetd套件产⽣的⼆进制⽂件⽐telnetd要⼩,但是utelnetd不⽀持internet super-server.下⾯先看busybox的 telnet功能。client很简单,选择上就可以⽤了;⽽telnetd则要相对⿇烦⼀些。 Telnetd的移植倒不⿇烦,busybox已经集成了⼀个。但是因为开始时 配置出现问题,所以费了些时间才算稳定。
(1)busybox的 配置 对Telnetd的 配置部分: Networking Utilities ---> [*]telnetd [*] Support standalone telnetd (notinetd only) 这个地⽅的 配置说明,telnetd可以由inetd来启动,也可以standalone启动。 (2)编译之后,因为telnetd是busybox的⼀部分,我在编译busybox时采⽤了动态编译的⽅法,所以只要把busybox依赖的动态库放到/lib下,就能保证telnetd不会产⽣找不到动态库的问题。所以在make;make install之后,telnetd算是到了 开发板上。但是仅仅这样还不能让telnetd正常运⾏。参考 配置telnetd时的help部分: A daemon for the TELNET protocol, allowing you to log onto the host running the daemon. Please keep inmind that the TELNET protocol sends passwords in plain text. If you can't afford the space for an SSH daemon and youtrust your network, you may say 'y' here. As a more secure alternative, you should seriously consider installing the verysmall Dropbear SSH daemon instead: Note that for busybox telnetd to work you need several things: First of all, yourkernel needs: UNIX98_PTYS=y DEVPTS_FS=y Next, you need a /dev/pts directory on your root filesystem: $ ls -ld/dev/pts drwxr-xr-x 2 root root 0 Sep 23 13:21 /dev/pts/ Next you need the pseudo terminal master multiplexer/dev/ptmx: $ ls -la /dev/ptmx crw-rw-rw- 1 root tty 5, 2 Sep 23 13:55 /dev/ptmx Any /dev/ttyp[0-9]* files you mayhave can be removed. Next, you need to mount the devpts filesystem on /dev/pts using: mount -t devpts devpts/dev/pts You need to be sure that Busybox has LOGIN and FEATURE_SUID enabled. And finally, you should make certainthat Busybox has been installed setuid root: chown /bin/busybox chmod 4755 /bin/busybox with all thatdone, telnetd _should_ 对Linux内核的 配置⽽⾔,默认已经满⾜。我出现错误主要是在mdev的初始化上,因为对mdev不熟悉,导致在安排⽂件挂载顺序时不合理,总是提⽰找不到/dev/pts。对于mdev如何安排顺序,应该看⼀下⽂档中的. ------------- MDEV Primer ------------- For those of us who know how to use mdev, a primer might seem lame. For everyone else, mdevis a weird black box that they hear is awesome, but can't seem to get their head around how it works. Thus, a primer. ----------- Basic Use ----------- Mdev has two primary uses: initial population and dynamic updates. Both require sysfs support in thekernel and have it mounted at /sys. For dynamic updates, you also need to have hotplugging enabled in your kernel. Here'sa typical code snippet from the init script: [1] mount -t sysfs sysfs /sys [2] echo /bin/mdev > /proc/sys/kernel/hotplug [3]mdev -s Of course, a more "full" setup would entail executing this before the previous code snippet: [4] mount -t tmpfsmdev /dev [5] mkdir /dev/pts [6] mount -t devpts devpts /dev/pts The simple explanation here is that [1] you need to have/sys mounted before executing mdev. Then you [2] instruct the kernel to execute /bin/mdev whenever a device is added orremoved so that the device node can be created or destroyed. Then you [3] seed /dev with all the device nodes that werecreated while the system was booting. For the "full" setup, you want to [4] make sure /dev is a tmpfs filesystem (assumingyou're running out of flash). Then you want to [5] create the /dev/pts mount point and finally [6] mount the devptsfilesystem on it. ------------- MDEV Config (/etc/) ------------- Mdev has an optional config file for controllingownership/permissions of device nodes if your system needs something more than the default root/root 660 file has the format:
发布者:admin,转转请注明出处:http://www.yc00.com/web/1688592537a153135.html
评论列表(0条)