通过Putty的SSH提出了“没有这样的文件或目录”

时间:2012-09-27 10:51:30

标签: linux ssh putty

我正在尝试通过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

导致这种情况的原因是什么?

谢谢!

2 个答案:

答案 0 :(得分:0)

bash很可能位于此linux框的不同位置/bin/bash

我发现在不同的盒子上就是这种情况,我已经将我的主目录中的.profile脚本更改为不直接执行bash,在您的情况下可能是一个解决方案。因此,当您登录时,您将保留在bourne shell中,然后仅在您明确键入bash时才进入bash shell。

答案 1 :(得分:0)

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

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

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