1

I use remote socks proxies for occasions when I need an IP from various locations. There is one that I use far more than any others, to the point that I would like a connection to be opened by default when my client machine boots.

Currently I have to open terminal, execute an SSH -D command, type in a password, and then the proxy is live. I would really like to automate this at startup somehow, but I can't seem to figure out how to do it. I'm intermediate with CLI stuff but a novice with shell scripting and so forth, so I really don't even know where to begin.

Is there an easy way to have this SSH connection start automatically at client startup?

So far in my searching for a solution, I have found this and am running as an automator workflow using the Run Shell Script module:

ip=aa.bb.cc.dd   #replace with your unix server's ip
username=yyyyyyyyyy #your ssh username
password=xxxxxxxxxxxxxxxxx #your ssh password
command=ssh -D 2002     #what do you want to do with remote server
arguments=-Cq     #arguments for your command
expect -c 'spawn ssh $username@$ip ; expect password ; send "$password\n" ; interact'

It seems to work, in that Automator gives no errors and reports Workflow completed. However the proxy is not accessible from a browser, so clearly something is wrong.

I'm using Mavericks, latest updates.

1

You need to pass the arguments to the ssh command you are running, not to some variables:

ip=aa.bb.cc.dd   #replace with your unix server's ip
username=yyyyyyyyyy #your ssh username
password=xxxxxxxxxxxxxxxxx #your ssh password
command="ssh -D 2002"     #what do you want to do with remote server
arguments=-Cq     #arguments for your command
expect -c 'spawn $command $arguments $username@$ip ; expect password ; send "$password\n" ; interact'
  • Aha... so can I not just include $command in the final line? Doing so isn't working for me... wondering why not? expect -c 'spawn $command $username@$ip ; expect password ; send "$password\n" ; interact' – Jonathan van Clute Dec 15 '16 at 20:16
  • Sure, if it looks better to you – Jakuje Dec 15 '16 at 20:16
  • but Automator doesn't seem to like that... ( "-: line 3: -D: command not found", "can't read "command": no such variable", " while executing", ""spawn $command $username@$ip " " ) – Jonathan van Clute Dec 15 '16 at 20:17
  • Maybe putting it into the " quotes? – Jakuje Dec 15 '16 at 20:18
  • Yep just had that exact same thought. Automator no longer complains, however my proxy still does not function. So close and yet... – Jonathan van Clute Dec 15 '16 at 20:19

You must log in to answer this question.

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