如何确定当前的远程连接类型? (rsh或ssh)

我想知道是否有一些方法可以找到当前连接类型到远程服务器(rsh或ssh?)。环境是Solaris 9,SuSE linux,csh。     
已邀请:
你可以使用
echo $SSH_CONNECTION;
。 SSH将在远程服务器上设置此环境变量。它包含客户端IP,客户端端口,服务器IP和服务器端口。它应该只为SSH连接设置。     
简答:测试
"$SSH_CLIENT$SSH2_CLIENT$SSH_TTY"
和谁连接谁是你的父母。 liquidprompt项目有一个(bash / zsh)函数来执行此操作,如下所示:
    # If this is an SSH connection.
    if [[ -n "$SSH_CLIENT$SSH2_CLIENT$SSH_TTY" ]] ; then
        # This is SSH.
    else
        # Get the host part of the who am i command.
        local sess_src="$(who am i | sed -n 's/.*((.*))/1/p')"
        # Get the name of the parent process.
        local sess_parent="$(ps -o comm= -p $PPID 2> /dev/null)"
        if [[ -z "$sess_src" && "$sess_src" = *"shepherd" ]] ; then
            # This is a qrsh connection (cf. Grid Engine).
        elif [[ -z "$sess_src" || "$sess_src" = ":"* ]] ; then
            # This is a local connection.
        elif [[ "$sess_parent" = "su" || "$sess_parent" = "sudo" ]] ; then
            # This is a su/sudo
        else
            # This (may be) telnet.
        fi
    fi
    

要回复问题请先登录注册