0

I use forward X windows connections a lot (using "ssh -X ...").

How can I see which window is from which user and machine?

Ideally I'd like each non-local window title bar to display "fred@server3.example.com" or similar.


Sorry, I hadn't made the question clear.

I'm not just asking about remote terminal windows, I'm asking about all X forwarded windows, such as Firefox, Thunderbird, etc.

fadedbee
  • 808
  • This depends on what terminal you use. Some look for escape sequences that change the title. For example, see here – meuh Apr 27 '19 at 14:28

1 Answers1

1

Your ~/.bashrc can tell if it's a ssh connection by looking at environment variables:

walt@bat:~(0)$ env | grep SSH
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
walt@bat:~(0)$ ssh $USER@localhost
walt@localhost's password: 
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-48-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

Last login: Sun Apr 21 11:09:24 2019
walt@bat:~(0)$ env | grep SSH
SSH_CLIENT=127.0.0.1 49228 22
SSH_TTY=/dev/pts/5
SSH_CONNECTION=127.0.0.1 49228 127.0.0.1 22
walt@bat:~(0)$ logout
Connection to localhost closed.

walt@bat:~(0)$ 

Then, you can use xttitle to set the window title (sudo apt install xttitle).

Something like

if [[ -n "$SSH_CONNECTION" ]] && [[ -n "$DISPLAY" ]] ; then
    xttitle "SSH Connection $USER@$(hostname)"
fi
waltinator
  • 36,399