I am using two linux machines to simulate some firewall tests… I execute the tests by running nc through ssh on a remote machine… if I spawn the ssh like this, it works…
ssh -i id_dsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-p 2224 root@a2-idf-lab nc -s 10.26.216.82 10.195.18.132 \
21 < /var/log/messages
However, if I try to control how much of /var/log/messages with head -c 20 /var/log/messages, the command hangs but I don’t understand why…
ssh -i id_dsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-p 2224 root@a2-idf-lab nc -s 10.26.216.82 10.195.18.132 \
21 < head -c 20 /var/log/messages
I also tried this with no better success…
ssh -i id_dsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-p 2224 root@a2-idf-lab nc -s 10.26.216.82 10.195.18.132 \
21 < (head -c 20 /var/log/messages)
Question: Why does the second command hang, and how can I accomplish what I need?
FYI, these experiments were really in preparation for sending cat /dev/urandom | base64 | head -c 20 - into nc… bonus points if you can give me cli that would work with nc through an ssh session…
<is shell redirection, it redirects the input stream to read from a file, not to execute a command. try:this pipes
/var/log/messagesfrom the local machine intoncon the remote machine.if you want to use the
/var/log/messagesfile on the remote machine, use quotes around the command: