0

My .ksh scripts in my mac usually run successfully, and until yesterday were initiating an ssh connection with the following command successfully:

ssh -o StrictHostKeychecking=no -o ServerAliveInterval=60 -i /tmp/priv.key -o ProxyCommand='ssh -o StrictHostKeychecking=no -o ServerAliveInterval=60 -i ~/.ssh/id_rsa -W %h:%p ' -p 22 user@<ip_address>

however it started giving following error from today

usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
           [-c cipher_spec] [-D [bind_address:]port] [-E log_file]
           [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
           [-J destination] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-P tag] [-p port] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           destination [command [argument ...]]
       ssh [-Q query_option]

Why is the ssh command failing while it was working fine few days ago?

1
  • Have you checked that /tmp/priv.key exists, contains what you need it to contain and is accessible? Does the command work if you run it manually? Commented Nov 4 at 15:05

1 Answer 1

0

Let's dissect your command and its options, using what for me is a standard problem partitioning approach:

ssh
-o StrictHostKeychecking=no
-o ServerAliveInterval=60
-i /tmp/priv.key
-o ProxyCommand='...'
-p 22
user@<ip_address>

All looks good. Now let's do the same for the ProxyCommand value:

ssh
-o StrictHostKeychecking=no
-o ServerAliveInterval=60
-i ~/.ssh/id_rsa
-W %h:%p

As you can see, the ssh command here is missing its target hostname. I can't tell whether the issue is that you've included -W or omitted its option, or whether %h:%p really does belong to -W but you've dropped the destination.

Either way, the command is invalid and so ssh prints out its usage message. This contains two set of options: the first the usual command-line and the second a simple -Q-based query mechanism. Notice that the usage provides a brief outline of the commands and their options, and in particular see [-W host:port].

To answer your specific question, "Why is the ssh command failing while it was working fine few days ago?", the answer has to be that someone or something has changed and broken your script. Does ls -ld -- {script} for an appropriate value of {script} show a recent modification time, perhaps?

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.