Re: Detecting whether a session is locally or remotely logged in
Brendon Oliver <[email protected]>
| Newsgroups | gmane.org.user-groups.mlug.main |
|---|---|
| Message-ID | <[email protected]> |
On Friday 26 August 2005 10:28, Tony Langdon wrote:
> Is there an easy way to determine if a shell session is local or
> remote to the system? I need to determine this for certain
> applications (specifically, GPG key generation), and want to idiot
> proof my scripts.
>
> Local can include in a local xterm as well as console.
>
> Remote includes remote xterms and SSH sessions (mostly SSH).
Are you trying to determine this from within the shell session or by
looking at it from the outside?
If you're doing it from within the shell, then ssh usually sets a few
env variables which might be helpful. eg. SSH_CLIENT, SSH_CONNECTION,
SSH_TTY. There might be others too... Obviously, they won't be
present if the shell is local to the system.
Hope this helps some.
Cheers,
- Brendon.
--
_______________________________________
/ I've got all the money I'll ever need \
| if I die by 4 o'clock. -- Henny |
\ Youngman /
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||