どのようなものSSH_TTYとSSH_CONNECTION変数については?私のUbuntuシステムでは、どちらも空白です。彼らはどんな価値を持っているべきですか?
どのようなものSSH_TTYとSSH_CONNECTION変数については?私のUbuntuシステムでは、どちらも空白です。彼らはどんな価値を持っているべきですか?
回答:
sshmanページから:
SSH_CONNECTION
Identifies the client and server ends of the connection.
The variable contains four space-separated values: client IP address,
client port number, server IP address, and server port number.
....
SSH_TTY
This is set to the name of the tty (path to the device) associated
with the current shell or command. If the current session has no tty,
this variable is not set.
sshセッションではないため、これらの変数は設定されていません。
man bashこれらの変数の意味を入力して検索できます。sshセッションにいるかどうかに関係なく、常に設定されます。
他の人が述べたように、これらの変数はセッションが行われたときにのみ設定されます。これを自分で確認するには、アクティブなSSHセッションで値を調べます。
ssh user@host 'echo SSH_TTY: $SSH_TTY SSH_CONNECTION: $SSH_CONNECTION'