2

I am making a script for my parents on their Mac's so that they can SSH into my Linux computer, and send commands, create popups etc.

This is one of my commands:

sshpass -p Password ssh maliciouzzhd@10.0.0.1 export DISPLAY=:0 & mate-session-save --force-logout

My problem is that the Mac treats the "&" as not in the sshpass script, and executes the argument after using the Mac terminal, no SSH.

So

sshpass -p Password ssh maliciouzzhd@10.0.0.1 export DISPLAY=:0 & mate-session-save --force-logout

would execute

export DISPLAY=:0

in the SSH session, but

mate-session-save --force-logout

would be executed in the Mac terminal.

If anyone could help me out with this, it would be greatly appreciated.

1

SSH accepts single argument as a command, not multiple ones, so the command line should look like this (note the quotes):

sshpass -p Password ssh maliciouzzhd@10.0.0.1 "export DISPLAY=:0 & mate-session-save --force-logout"

But the general idea might not work, because you didn't allow X11 forwarding (add -Y switch to the ssh).

  • Thanks, it works, but it is now saying Unable to init server: Could not connect: Connection refused – MaliciouZzHD Feb 3 '17 at 7:48
  • Do you have X server installed on your mac? – Jakuje Feb 3 '17 at 8:10
  • How do I check? I'm not use to Mac, its my parents – MaliciouZzHD Feb 3 '17 at 8:19
  • support.apple.com/en-us/HT201341 -- you need to install XQuartz manually – Jakuje Feb 3 '17 at 8:21
  • Wait... I am trying to control my Linux laptop through SSH from my Mac, do I need XQuartz on my Mac too? My Linux definitely has XServer stuff on it. – MaliciouZzHD Feb 3 '17 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .