Find the answer to your Linux question:
Results 1 to 5 of 5
I’m having trouble making a server connection with netcat. I first connect to Server A through Putty, then try to forward the connection to Server B with “nc serverb 22”. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    2

    Netcat connection not working

    I’m having trouble making a server connection with netcat. I first connect to Server A through Putty, then try to forward the connection to Server B with “nc serverb 22”. With the verbose flag turned on, I get a message saying the connection was successful, then the SSH version installed on Server B, then the process hangs for several minutes. Finally, it quits out back to Server A’s command prompt.

    I’ve tried running netcat with the verbose and debug flags on and I’ve tried connecting to and from three different servers. I get exactly the same result every time. Syslogs don’t seem to have any information at all about the connection attempts. Does netcat itself keep logs that I can check? Has anyone seen this problem before?

  2. #2
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,789
    Let me get this straight, you're trying to connect to Server B from your client using Server A as a "tunnel" for want of a better way of explaining it?

    If so, why not use SSH's port forwarding feature.

    e.g.

    Code:
    ssh -L 2022:ServerB'sIP:22 ServerA
    This will map your "localhost:2022" port to Server B's 22 port, therefore, running
    Code:
    ssh localhost -p 2022
    , will connect to serverB
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  3. #3
    Just Joined!
    Join Date
    Jun 2011
    Posts
    2
    Quote Originally Posted by sdousley View Post
    Let me get this straight, you're trying to connect to Server B from your client using Server A as a "tunnel" for want of a better way of explaining it?

    If so, why not use SSH's port forwarding feature.

    There are two problems with doing it that way.

    1) I ultimately want to be able to tunnel through more than one server before reaching the endpoint. I don't know of a way to do that with port forwarding.

    2) I want a fully encrypted tunnel- using port forwarding, data is decrypted and re-encrypted at each server in the chain (or so I've been told).

    In theory, Netcat sounds perfect for my purposes. If only I could actually get it to work!

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    3,694
    Have you checked out iptables? You can forward all inbound TCP traffic on some port (e.g. 22) on server A to the ip address/port of server B (and it can do the same to server C, etc.).

  5. #5
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    If my memory serves me correctly, netcat won't support encrypted connections. They added all the features of netcat into openssh. But I digress. I believe you can find what you are trying to do here: 25 Best SSH Commands / Tricks
    linux user # 503963

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •