Using Netcat command to download file from remote device
Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using Netcat command to download file from remote device
How to use Netcat command to download file (mtdblock) /dev/mtdblock3 from remote machine (which runs embedded Linux, BusyBox v1.4.2) to local computer? The remote machine and local computer are inside different private networks. Also, the local computer connected behind a NAT router.
nc
nc [OPTIONS] HOST PORT - connect nc [OPTIONS] -l -p PORT [HOST] [PORT] - listen
Options:
-e PROG Run PROG after connect (must be last)
-l Listen mode, for inbound connects
-n Don't do DNS resolution
-s ADDR Local address
-p PORT Local port
-u UDP mode
-v Verbose
-w SEC Timeout for connects and final net reads
-i SEC Delay interval for lines sent
-o FILE Hex dump traffic
-z Zero-I/O mode (scanning)
How to use Netcat command to download file (mtdblock) /dev/mtdblock3 from remote machine (which runs embedded Linux, BusyBox v1.4.2) to local computer? The remote machine and local computer are inside different private networks. Also, the local computer connected behind a NAT router.
If your local computer is behind a NAT router then if you can make the remote device listen you spare yourself the effort of having to set up port forwarding. For example if you can SSH into the machine and you have sufficient rights to perform this you could try 'ssh user@remote.host "dd if=/dev/mtdblock3" > /tmp/mtdblock3.dd;' which is better than using 'nc' because you probably don't want to move memory contents over the network unencrypted? If you can't then on the remote machine pipe 'dd' output through 'nc' in listening mode and then on the local machine connect to the remote machine + port and pipe to a file.
If your local computer is behind a NAT router then if you can make the remote device listen you spare yourself the effort of having to set up port forwarding. For example if you can SSH into the machine and you have sufficient rights to perform this you could try 'ssh user@remote.host "dd if=/dev/mtdblock3" > /tmp/mtdblock3.dd;' which is better than using 'nc' because you probably don't want to move memory contents over the network unencrypted? If you can't then on the remote machine pipe 'dd' output through 'nc' in listening mode and then on the local machine connect to the remote machine + port and pipe to a file.
The issue with netcat not solved yet. I can't download anything with netcat command due to connection timed out. SSH is not supported, only telnet. The TFTP works for small files, but failed for larger files.
should I use same command as in previous thread?
on local:
nc -l -p 5555 > UBFI1
I can't download anything with netcat command due to connection timed out.
It is most efficient if you tell us exactly what services can or can not be used, what commands you have tried and what errors you get in your initial post.
Quote:
Originally Posted by dorsio
The TFTP works for small files, but failed for larger files.
See if busybox provides 'split' command then download each part?
Quote:
Originally Posted by dorsio
should I use same command as in previous thread?
on local:
nc -l -p 5555 > UBFI1
That may or may not work depending on if the remote machine can reach the local machine. You talked about NAT so if you didn't set up port forwarding in your router it is unclear how this could work.
It is most efficient if you tell us exactly what services can or can not be used, what commands you have tried and what errors you get in your initial post.
See if busybox provides 'split' command then download each part?
That may or may not work depending on if the remote machine can reach the local machine. You talked about NAT so if you didn't set up port forwarding in your router it is unclear how this could work.
The errors are same as in previous thread.
'Split' command not supported in busybox implementation. But 'tar' function is supported: not sure if this can help in my case.
Sure, I configured port forwarding on my router, this should not prevent connection. But I tried also without router, too.
I'm not sure about count=3a value: should be hex division calculated in HEX or Decimal units?
Why? I will use external IP address. Please explain detaily.
Quote:
Originally Posted by unSpawn
No, let's turn that around: you read 'man dd' then you propose what you think your command line should be, then I'll correct if necessary.
Linux DD man is vague and don't tell how to calculate count value and which unit need be 'N' blocks. Also there is no any examples of using that commands.
count=N
copy only N input blocks
This bytes in HEX format? bs=BYTES
read and write up to BYTES bytes at a time
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.