我犯了一个愚蠢的错误...我正在玩 busybox,并将chsh
根 shell 从 /bin/sh 切换到 /bin/busybox,这似乎破坏了 SSH 访问。
当我做:
root@dev:~$ ssh [email protected]
我得到:
[email protected]'s password:
BusyBox v1.22.1 (2015-06-19 07:36:41 CEST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2012.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
Usage: busybox [function [arguments]...]
or: busybox --list
or: function [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.
Currently defined functions:
[, [[, addgroup, adduser, ar, ash, awk, basename, brctl, bunzip2, bzcat, cat, chattr, chgrp, chmod, chown, chroot, chvt, clear, cmp, cp, cpio, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, df,
diff, dirname, dmesg, dnsdomainname, du, dumpkmap, dumpleases, echo, egrep, env, expr, false, fbset, fdisk, fgrep, find, flock, free, fsck, fstrim, fuser, getty, grep, groups, gunzip, gzip, halt, head,
hexdump, hostname, hwclock, id, ifconfig, ifdown, ifup, insmod, ip, kill, killall, less, ln, loadfont, loadkmap, logger, logname, losetup, ls, lsmod, md5sum, microcom, mkdir, mkfifo, mknod, mkswap,
mktemp, modprobe, more, mount, mv, nc, netstat, nohup, nslookup, od, openvt, patch, pidof, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, realpath, reboot, renice, reset, rfkill, rm, rmdir,
rmmod, route, run-parts, sed, seq, setconsole, sh, sha3sum, sleep, sort, start-stop-daemon, stat, strings, stty, sulogin, swapoff, swapon, switch_root, sync, sysctl, tail, tar, tee, telnet, test, tftp,
time, top, touch, tr, true, tty, udhcpc, udhcpd, umount, uname, uniq, unzip, uptime, users, usleep, vi, watch, wc, wget, which, who, whoami, xargs, yes, zcat
Connection to ip.of.ser.ver closed.
从技术上讲,我不确定它为什么会关闭连接。从非技术上讲,我不知道如何修复此问题,并且希望重新获得对设备的访问权限。
据我所知,我只需要编辑/etc/passwd
并将其改回来,但对于现在发生的情况,我该怎么做呢?
答案1
连接已关闭,因为调用/bin/busybox
只会显示您看到的输出,但不会启动 shell 会话(请在终端中尝试)。您需要创建符号链接
/usr/bin/ash -> /bin/busybox
并调用/usr/bin/ash
以启动 busybox shell。
您可能必须通过救援系统来修复此问题才能将其改回来。
答案2
如果您已启用该计算机的 SFTP 访问权限,请尝试使用它。很可能它配置为不需要有效的 shell(internal-sftp)。然后您可以编辑您的密码文件 /etc/passwd文件。