Ssh argument length: Difference between revisions
m (New page: On Solaris 10, you can create command up to about 1MB in length. <geshi lang="bash"> $ getconf ARG_MAX 1048320 </geshi> However, what is the max length of a command which you can execute...) |
mNo edit summary |
||
Line 54: | Line 54: | ||
If you need more than is, one could pipe the command into stdin and then execute it, or create a script on the remote side and execute that script. | If you need more than is, one could pipe the command into stdin and then execute it, or create a script on the remote side and execute that script. | ||
If you default shell is csh, you will get output like | |||
<pre> | |||
$ ~/bin/check-sshlength.sh everest | |||
Received disconnect from 10.0.0.92: 2: Bad packet length 1000044. | |||
Received disconnect from 10.0.0.92: 2: Bad packet length 500044. | |||
Word too longth 250000 | |||
Word too longth 125000 | |||
Word too longth 62500 | |||
Word too longth 31250 | |||
Word too longth 15625 | |||
Word too longth 7813 | |||
Word too longth 3907 | |||
Word too longth 1954 | |||
Word too longth 1466 | |||
Word too longth 1222 | |||
Word too longth 1100 | |||
Word too longth 1039 | |||
Word too longth 1024 | |||
Word too longth 1020 | |||
Maximum ssh argument length between everest and everest is 1019 | |||
</pre> | |||
See [http://www.grymoire.com/Unix/CshTop10.txt Top Ten Reasons not to use the C shell] | |||
[[Category:Solaris]] | [[Category:Solaris]] |
Revision as of 05:33, 30 March 2009
On Solaris 10, you can create command up to about 1MB in length.
<geshi lang="bash"> $ getconf ARG_MAX 1048320 </geshi>
However, what is the max length of a command which you can execute via ssh? To answer this, I wrote a basic script to test this.
<geshi lang="bash">
- !/bin/bash
- usage: <host> <arg size guess>
host=${1-localhost} mid=${2-1048320} r=$((mid/2))
while [ $r -gt 0 ]; do
printf "Checking length $mid \r" l=$(ssh $host printf "$(yes | base64 -w 0 | head -c$mid)" | wc -c) if [ $l -eq $mid ]; then mid=$((mid+r)) else mid=$((mid-r)) fi r=$((r/2))
done
echo echo "Maximum ssh argument length between $(hostname) and $host is $mid" </geshi>
The results of the script look like:
~/bin/check-sshlength.sh everest Received disconnect from 10.0.0.92: 2: Bad packet length 1000044. Received disconnect from 10.0.0.92: 2: Bad packet length 500044. Received disconnect from 10.0.0.92: 2: Bad packet length 375036. Received disconnect from 10.0.0.92: 2: Bad packet length 312540. Received disconnect from 10.0.0.92: 2: Bad packet length 281292. Received disconnect from 10.0.0.92: 2: Bad packet length 265660. Received disconnect from 10.0.0.92: 2: Bad packet length 263708. Received disconnect from 10.0.0.92: 2: Bad packet length 262732. Received disconnect from 10.0.0.92: 2: Bad packet length 262252. Received disconnect from 10.0.0.92: 2: Bad packet length 262188. Received disconnect from 10.0.0.92: 2: Bad packet length 262156. Received disconnect from 10.0.0.92: 2: Bad packet length 262156. Maximum ssh argument length between everest and everest is 262111
This makes sense as this jives with the maximum packet length of an ssh session. http://www.free.lp.se/fish/rfc.txt
If you need more than is, one could pipe the command into stdin and then execute it, or create a script on the remote side and execute that script.
If you default shell is csh, you will get output like
$ ~/bin/check-sshlength.sh everest Received disconnect from 10.0.0.92: 2: Bad packet length 1000044. Received disconnect from 10.0.0.92: 2: Bad packet length 500044. Word too longth 250000 Word too longth 125000 Word too longth 62500 Word too longth 31250 Word too longth 15625 Word too longth 7813 Word too longth 3907 Word too longth 1954 Word too longth 1466 Word too longth 1222 Word too longth 1100 Word too longth 1039 Word too longth 1024 Word too longth 1020 Maximum ssh argument length between everest and everest is 1019