gpt4 book ai didi

linux - 通过 Putty 进行 SSH 会出现 "no such file or directory"

转载 作者:太空宇宙 更新时间:2023-11-04 04:21:34 25 4
gpt4 key购买 nike

我正在尝试通过 Putty 访问 Linux 服务器,但由于某种原因,在成功登录后,它只是抛出“/bin/bash 没有这样的文件或目录”,然后 Putty 关闭。

bashrc 的内容:

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# By default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi

if ! shopt -q login_shell ; then # We're not a login shell
# Need to redefine pathmunge, it get's undefined at the end of /etc/profile
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

# Only display echos from profile.d scripts if we are no login shell
# and interactive - otherwise just process them to set envvars
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. $i
else
. $i >/dev/null 2>&1
fi
fi
done

unset i
unset pathmunge
fi
# vim:ts=4:sw=4

这可能是什么原因造成的?

谢谢!

最佳答案

检查您的 /etc/ssh/sshd_config 以确保您没有设置 chroot 目录。如果这样做,您将需要在 chroot 目录中创建一个 bin 目录,并将必要的二进制文件复制或链接到该目录中。

或者您可以随时在配置中注释掉该行。

无论哪种方式,重新启动 sshd 并测试

关于linux - 通过 Putty 进行 SSH 会出现 "no such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12619689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com