Ssh and input length

Hello,
sometimes I need to enter a command that exceeds the maximum line limit for ssh
Is it possible to increase this limit?

Thanks

  • Copy command to a file in /tmp
  • chmod +x
  • Execute command
  • Is this an OpenWrt device?
    • If so, what version?
  • What is this "line limit"?
  • Can you show an example?
2 Likes

Yes the trick of creating a file is what I have been doing, but it is somewhat uncomfortable.

MediaTek MT7621 OpenWrt 21.02.3

Sometimes I download something from a free slow server to leave hours downloading to a USB with Curl. And many times the url does not fit in the command

Example:

curl 'https://duckduckgo.com/assets/icons/meta/DDG-iOS-icon_152x152.png' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0' -H 'Accept: image/avif,image/webp,*/*' -H 'Accept-Language: es-ES,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Referer: https://duckduckgo.com/' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Sec-Fetch-Dest: image' -H 'Sec-Fetch-Mode: no-cors' -H 'Sec-Fetch-Site: same-origin' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers' -JO


root@OpenWrt:~# curl 'https://duckduckgo.com/assets/icons/meta/DDG-iOS-icon_152x152.png' -H 'User-Agent: Mozil
la/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0' -H 'Accept: image/avif,image/webp,*/*' -H '
Accept-Language: es-ES,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Referer: https://duckduckgo.com/'
 -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Sec-Fetch-Dest: image' -H 'Sec-Fetch-Mode: no-cors' -H 'Sec-Fetch
-Site: same-origin' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailer

Have you actually checked that you absolutely need all the headers you're specifying, like e.g. if you're downloading binary files, then specifying what languages you accept isn't going to actually change anything.

It is only an example of capacity, in real use I do not include any header only the url is very long.

Is it a dropbear limitation or is it configurable?

1 Like

This is not a limit in ssh. It is a command line length limit in the ash shell.
I encountered this problem a while ago. I don't recall the exact size limit but is around 1024 characters I think.
I got round it by piping the output of a file into the executable.
eg try something like

cat /tmp/mycommandline.txt | command_executable
3 Likes

For now I was doing,

#!/bin/bash
command_executable

thanks for the suggestion

"ash shell" is also not configurable that we know of isn't it?

Bash is not available by default. Do you mean you have installed it to fix the problem?
It should be:
#!/bin/sh
for ash.

2 Likes

Right, I installed it for a script of my own that was more complex than sh allowed.

Well, if you have bash, then you've already fixed the issue. Try:rurning just "bash." That should put you into the bash shell. Then run the command:

root@openwrt:~# echo $SHELL
/bin/ash
root@openwrt:~# command with...my...really....long...argument
Danger, Will Robinson! Danger! argument too long
root@openwrt:~# bash
root@new-bash-prompt:~# echo $SHELL
/bin/bash
root@new-bash-prompt:~# command with...my...really....long...argument
You got it, doc!
root@new-bash-prompt:~# exit
root@openwrt:~# echo am I back to $SHELL now?
am I back to /bin/ash now?

(Note: I don't have bash on my router yet so the above is just speculation of how I'd expect it to do.)

2 Likes

Yes, it works, it is the most convenient solution :smiley:

thank you very much

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.