I have ssh access to my flatmate's computer (Ubuntu 14.04). I want to send her a message via ssh, thus I use this command

export DISPLAY=:0 && notify-send "sample message"

The command exits with 0, but she sees no message. On the other hand, when I use export DISPLAY=:0 and e.g. xterm, the xterm normally opens. libnotify is installed, when I run notify-send locally, it shows. Also, when I try this command via ssh on another computer, it works.

Any ideas, why is this happening, please? Thank you


notify-send needs to have session credentials to be able to send notifications within your friends session. These are stored in Environment variables included in a session when you login, this prevents rogue background processes from messing up your desktop.

An easy way to make these session credentials available (and subvert the security of the desktop completely) is to have the desktop session start a screen session and then background it.

you can then ssh to it , connect to the screen session and then your notify-send will work. If you do this ensure your flatmate is fully aware that you have total access to her desktop and files.

To configure the screen session:

From the dash run 'Startup Applications'

click add , give it a name and enter the following in command:

screen -dmS desktop_session

Then when you connect via ssh

screen -r desktop_session
notify-send "Insecure message"

You can then run any command and have its graphical output appear on that desktop session.

You will need to do this interactively, if you want to do it non-interactively you could have a shell script poll a file and when it has data send it to notify. or just use an instant message client.

  • Thank you for your reply, but: screen was not installed. I installed it and continued as you wrote. Still no change. However, I can open any other application (also with export DISPLAY=:0) in graphical mode. I have ssh access to another computer with 14.04 and it works perfectly just with DISPLAY variable. – Michal Polovka May 16 '16 at 5:24
  • i have used this since before 14.04 all the way up to the current 16.04. As i said DISPLAY only points to the location , the authentication is in the sesssion variables – Amias May 16 '16 at 9:07
  • I believe you, but it just simply does not work, so the problem would be probably somewhere else. – Michal Polovka May 16 '16 at 9:26
  • if you dump ('set > active_envs') and compare (' diff desktop_active_envs screen_active_envs') the environment variables from both shells you can find the missing parts. – Amias May 16 '16 at 12:49
  • you could try it on freshly made accounts to see if its something odd in your user settings or a bug in the software – Amias May 30 '16 at 9:30

I had to do a similar thing - I would run an update on one computer but wanted a notify-send on another computer. I used sshpass:

sshpass -p user_password ssh -X user_name@ip_address DISPLAY=:0 notify-send "The message"

where you would replace user_password, user_name and ip_address for your specific user/machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.