Home » Questions » Computers [ Ask a new question ]

How can I tell if I am SSH'd in somwhere already?

How can I tell if I am SSH'd in somwhere already?

Is there an easy way to tell if I am SSH'd in somewhere without typing 'exit'?

Asked by: Guest | Views: 55
Total answers/comments: 2
Guest [Entry]

Check out $SSH_CONNECTION. It tells you which IP and port you are currently connecting from and to. At least, this is the case with OpenSSH. YMMV with other servers.
Guest [Entry]

Try setting your prompt to include the hostname; otherwise I like to use screen on every login with a status line containing the hostname (a bit complicated to setup, and it gets recursive with status lines within screens with status lines). You should be able to echo $HOSTNAME or just execute hostname.