リモートサーバーへの現在の接続タイプ (rsh または ssh?) を調べる方法があるかどうかを知りたいです。環境はSolaris 9、SuSE Linux、cshです。
2 に答える
1
使用できますecho $SSH_CONNECTION;
。SSH は、この環境変数をリモート サーバーに設定します。これには、クライアント IP、クライアント ポート、サーバー IP、およびサーバー ポートが含まれます。SSH 接続に対してのみ設定する必要があります。
于 2010-08-26T14:56:31.190 に答える
0
簡単な答え : テストし、"$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
于 2015-04-20T09:50:50.940 に答える