Ssh argument length
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.