Auto export display when coming from SSH

[ -n "$SSH_CLIENT" ] && export DISPLAY=$(echo $SSH_CLIENT | awk '{ print $1 }'):0.0
In some case, you need to use remote gui on servers or simple machines and it's boring to see "cannot open display on ..." if you forgot to export your display. Juste add this line in .bashrc on remote machine. Dont forget to allow remote client on your local X server : xhost +

By: GouNiNi
2010-04-14 08:19:37

What Others Think

Why on earth? "xhost +" is dangerous, why don't you use "ssh -X remote_host"? Why .bashrc? There are lots of shells, not everyone is using bash, try to make your solutions portable!
OJM · 637 weeks and 1 day ago
"ssh -X remote_host" dont work every time, ie if sshd_config disable X11Forwarding. About .bashrc, it should work in .profile
GouNiNi · 637 weeks and 1 day ago
If someone disables X11 forwarding it is on purpose, no need to send data over insecure channels just because you can.
OJM · 637 weeks and 1 day ago ????? ??? ????? ???? SEO ????? ????? ????? ???? ????? ????? ??? ???? ???? ??????? Search Engine Optimization ??? ????? ??????????? ?? ????? ?????????? ????? ????? ?? ????
seofox · 21 weeks and 4 days ago
seofox · 20 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: