Telnet协议是TCP/IP协议族中的一员,是Internet远程登录服务的标准协议和主要方式。它为用户提供了在本地计算机上完成远程主机工作的能力。在终端使用者的电脑上使用telnet程序,用它连接到服务器。终端使用者可以在telnet程序中输入命令,这些命令会在服务器上运行,就像直接在服务器的控制台上输入一样。可以在本地就能控制服务器。要开始一个telnet会话,必须输入用户名和密码来登录服务器。Telnet是常用的远程控制Web服务器的方法。
一、启用用户登录
https://blog.csdn.net/weixin_43782998/article/details/121285658
二、busybox
telnet需要一个交互的登录界面,须要有getty、login和passwd程序。如果没有,无法实现telnet。此三个程序可由busybox生成。
1、telnet、telnetd
Networking Utilities --->[*] telnet[*] Pass TERM type to remote host{*} Pass USER type to remote host[*] telnetd[*] Support standalone telnetd (not innetd only)[*] Support -w SEC option (inetd wati mode)
2、 inetd
Networking Utilities --->[*] inetd
3、mdev
Linux System Utilities --->[*] mdev[*] Support /etc/mdev.conf[*] Support subdirs/symlinks[*] Support regular expressions substitutions when renaming device[*] Support command executiong at device addition/removal[*] Support loading of firmwares
三、kernel
修改内核配置,启用Legacy (BSD) PTY support。
Device Drivers --->Character devices --->-*- Unix98 PTY support[] Support multiple instances of devpts[*] Legacy (BSD) PTY support(256) Maximum number of legacy PTY in use
四、rootfs
1、/etc/services
直接拷贝Ubuntu下的对应文件。
2、/etc/inetd.conf
# /etc/inetd.conf: see inetd(8) for further informations.
#
# Internet server configuration database
#
# If you want to disable an entry so it isn't touched during
# package updates just comment it out with a single '#' character.
#
# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>
#
#:INTERNAL: Internal services
#echo stream tcp nowait root internal
#echo dgram udp wait root internal
#chargen stream tcp nowait root internal
#chargen dgram udp wait root internal
#discard stream tcp nowait root internal
#discard dgram udp wait root internal
#daytime stream tcp nowait root internal
#daytime dgram udp wait root internal
#time stream tcp nowait root internal
#time dgram udp wait root internali# These are standard services.
#telnet stream tcp nowait root /usr/sbin/telnetd telnetd -i
tftp dgram udp wait nobody /bin/tftpd
ftp stream tcp nowait root /usr/sbin/ftpd bftpd
3、/etc/rc.d/netd
须追加执行权限。
#!/bin/shbase=inetd# See how we were called.
case "$1" instart)/usr/sbin/$base;;stop)pid=`/bin/pidof $base`if [ -n "$pid" ]; thenkill -9 $pidfi;;
esacexit 0
4、/etc/hostname
moshui
5、/etc/fstab
proc /proc proc defaults 0 0
none /var/shm shm defaults 0 0
sysfs /sys sysfs defaults 0 0
none /tmp ramfs defaults 0 0
none /mnt ramfs defaults 0 0
6、/etc/mdev.conf
sd[a-z][0-9] 0:0 666 @/etc/hotplug/usb/usb_insert
sd[a-z] 0:0 666 $/etc/hotplug/usb/usb_remove
mmcblk[0-9]p[0-9] 0:0 660 @/etc/hotplug/sd/sd_insert
mmcblk[0-9] 0:0 660 $/etc/hotplug/sd/sd_remove
或
mmcblk([0-9]+)p([0-9]+) 0:0 660 */sbin/automount.sh $MDEV X${ACTION}
mmcblk([0-9]+) 0:0 660 */sbin/automount.sh $MDEV X${ACTION}
sd([a-z]+)([0-9]+) 0:0 660 */sbin/automount.sh $MDEV X${ACTION}
sd([a-z]+) 0:0 660 */sbin/automount.sh $MDEV X${ACTION}
#mtdblock([0-9]+) 0:0 660 */sbin/automount.sh $MDEV X${ACTION}
/sbin/automount.sh,须追加执行权限。
#! /bin/sh# debugging message
#echo "MDEV=$1 : ACTION=$2 : SUBSYSTEM=$SUBSYSTEM : DEVPATH=$DEVPATH : DEVNAME=$DEVNAME" >> /dev/consoleif [ "$1" == "" ]; thenecho "parameter is none" > /tmp/error.txtexit 1
fiMNT=$1
#if [ $(echo $1 | grep mmcblk) ]; then
# if [ $(echo $1 | grep p[25]) ]; then
# MNT=sdcard2
# else
# MNT=sdcard
# fi
#elif [ $(echo $1 | grep sd) ]; then
# if [ $(echo $1 | grep p[25]) ]; then
# MNT=nandcard2
# else
# MNT=nandcard
# fi
#fi# there is no ACTION, it is for initial population
if [ "$2" = "X" ]; thenmounted=`mount | grep $1 | wc -l`if [ $mounted -ge 1 ]; then# mounted, assume the ACTION is remove#ACT=Xremove# only set add for initial populationACT=Xaddelse# not mounted, assume the ACTION is addACT=Xaddfi
elseACT=$2
fiif [ "$ACT" = "Xremove" ]; then# umount the deviceecho "$ACT /mnt/$1" >> /tmp/mdev.logif ! umount -l "/mnt/$1"; thenexit 1elserm -f "/mnt/$MNT"echo "[Umount FS]: /dev/$1 -X-> /mnt/$MNT" > /dev/consolefiif ! rmdir "/mnt/$1"; thenexit 1fi
else# mount the devicemounted=`mount | grep $1 | wc -l`#echo "par=$1,mounted=$mounted,MNT=$MNT" > /dev/consoleif [ $mounted -ge 1 ]; then#echo "device $1 is already mounted" > /dev/consoleexit 0fiif ! mkdir -p "/mnt/$1"; thenexit 1fiif [ $(echo $1 | grep mtd) ]; thenif mount -t jffs2 "/dev/$1" "/mnt/$1"; thenecho "[Mount JFFS2]: /dev/$1 --> /mnt/$MNT" > /dev/consoleecho "$ACT /mnt/$1" >> /tmp/mdev.logelif mount -t yaffs2 -o"inband-tags" "/dev/$1" "/mnt/$1"; thenecho "[Mount YAFFS2]: /dev/$1 --> /mnt/$MNT" > /dev/consoleecho "$ACT /mnt/$1" >> /tmp/mdev.logelif mount -t ubifs "/dev/$1" "/mnt/$1"; thenecho "[Mount UBIFS]: /dev/$1 --> /mnt/$MNT" > /dev/consoleecho "$ACT /mnt/$1" >> /tmp/mdev.logelse# failed to mount, clean up mountpointif ! rmdir "/mnt/$1"; thenexit 1fifielse# try vfat onlyif mount -t vfat -o noatime,shortname=mixed,utf8 "/dev/$1" "/mnt/$1"; thenln -s /mnt/$1 /mnt/$MNTecho "[Mount VFAT]: /dev/$1 --> /mnt/$MNT" > /dev/consoleecho "$ACT /mnt/$1" >> /tmp/mdev.logelse# failed to mount, clean up mountpointif ! rmdir "/mnt/$1"; thenexit 1fiexit 1fifi
fi
7、/etc/init.d/rcS
hostname -F /etc/hostnameecho /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev -smkdir -p /dev/pts
mount -t devpts devpts /dev/pts
或
mount -n -t devpts none /dev/pts -o mode=0622mkdir /dev/pts
mount devpts -t devpts /dev/pts //加载devpts文件系统inetd
或
/etc/rc.d/netd start