The following shell script works only for first server and does not loop to the next. I tried 0< before the ssh command but it still does not return to the shell script once connected.
#!/bin/sh while read IP do ssh [email protected] " ssh root@$IP 'ls -lht /log/cdr-csv/ ' " > /tmp/$IP.txt done << here_doc 18.17.6.19 18.17.10.24 here_doc How do I run the same command on the second server 18.17.10.24 ?

set -xto the top of your script. Where does it stop?ssh -v