Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8757487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:18:48+00:00 2026-06-13T14:18:48+00:00

I am using two linux machines to simulate some firewall tests… I execute the

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:18:49+00:00Added an answer on June 13, 2026 at 2:18 pm

    < is shell redirection, it redirects the input stream to read from a file, not to execute a command. try:

    head -c 20 /var/log/messages | 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 
    

    this pipes /var/log/messages from the local machine into nc on the remote machine.
    if you want to use the /var/log/messages file on the remote machine, use quotes around the command:

    ssh -i id_dsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
      -p 2224 root@a2-idf-lab "head -c 20 /var/log/messages |\
         nc -s 10.26.216.82 10.195.18.132 21"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two linux machines. On one machine I'm using a thread which starts
I need to create an ssh connection between two Linux machines running Centos v5
I am trying to ssh into a remote Linux server using x11. I found
I have two legacy machines connected to a Linux box with USB using the
I have two machines I work on: Windows Client (Development Machine) Linux Web Server
We have two machines which need to communicate: a Linux based gateway, and a
How to get all IP adresses of a Linux machine using Java? My device
I usually sync two computers (mac and linux) using rsync so that I can
I Using Two Table User And Location In User Table I having LocationId And
I am using two jQuery scripts. One is for controlling the drop down navigation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.