1

I need to open an ssh connection on login and keep it open, but to not acutally do anything with it. It would be best if all of it would run in the background.

I created an automator application and made it run a shell script on the bash. The script looks as follows:

sshpass -p 123456 ssh 123456@123.123.123.123

If i try to run the application i keep getting an error message, however if i execute the exact same script in an terminal it works just fine.

Is there any way i can open that connection with an automator application and keep in the background?

davidf
  • 170
  • 1
  • 1
  • 9
  • "If i try to run the application i keep getting an error message, however if i execute the exact same script in an terminal it works just fine." What is the error message? What is the script? – Kenster Oct 05 '14 at 16:11

2 Answers2

1

You can send a KeepAlive packet to stop the pipe from closing.

In your ~/.ssh/config, and the following:

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

What this says is that that every 300 seconds, send a null (keep-alive) packet and give up after 2 tries.

Source: http://patrickmylund.com/blog/how-to-keep-alive-ssh-sessions/

jonalmeida
  • 1,206
  • 1
  • 9
  • 24
0

Do you really need to involve Automator at all?

Just save the script (say, foo.sh) in a folder with the same name as the script (i.e. foo.sh as well). Put this folder in /System/Library/StartupItems/ and it will run when you start up your machine.

Travis
  • 2,579
  • 18
  • 19