11

I have the following line in my .bashrc

xmodmap -e "keycode 116 = slash"

when I SSH to that machine, I get

xmodmap:  unable to open display ''

and needless to say, I want it out of there. Can anyone let me know how to clean this error?

OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007

Thank you for your help.

2 Answers2

13

You could change your .bashrc to only do run xmodmap if there is a display available:

if [ -n "${DISPLAY+x}" ]; then
    xmodmap -e "keycode 116 = slash"
fi
innaM
  • 10,412
1

That error is probably because you didn't enable X11 forwarding. Just run ssh with the -X option (ie

ssh -X -l user server.tld

or in putty click the option goto SSH -> X11 -> Enable X11 forwarding.

Of course you need to be running an Xserver first before you SSH in, Linux has this by default, where if you are running Windows you can use Xming.

If you don't use an X11 session whenever you SSH in, then just use Manni's solution.