I have an attendance device running Linux OS
. I can connect this device via telnet session. There are some files in the device that I would like to download and upload with new files. How can I do that? I have very low knowledge on Linux OS. Would you please help!

- 371
8 Answers
This depends which tools are installed on the client device / supported by the kernel.
Possible methods for file transfer (unordered):
- ssh / sftp
- encoding binary files into displayable format with base64/uuencode and then copy from/into your telnet terminal window.
- over a simple tcp connection with
netcat
orsocat
or withbash
and /dev/tcp - upload / download with
wget
orcurl
from a web server - ftp server with a command line ftp client
- samba or nfs mount
Read Simple file transfer and How to get file to a host when all you have is a serial console? for more possibilites.
Copy desktop.jpg
from the device to your pc with the netcat/nc method:
On your pc, disable temporarily (or reconfigure if possible) any firewall and run
netcat -l -p 10000 > desktop.jpg
and on the device
busybox nc A.B.C.D -p 10000 < desktop.jpg
where you need to replace A.B.C.D with the IP address of your pc. As soon as the transfer was successful, the netcat process on your pc should stop automatically. If not, something could have gone wrong and you can stop it with Ctrl+C (compare source and destination checksums to verify).
For the other direction, just exchange <
and >
on both sides. Make first a backup of the original desktop.jpg
(cp desktop.jpg desktop_orig.jpg
).
-
I tried WinSCP utility and tried to connect the device using ftp/sftp/scp protocol. but it is not getting connected. I am able to connect the device via telnet command and able to see the files that I want to get and upload again into device. – PRdeep Kumawat Dec 04 '14 at 12:49
-
-
Well I don't know that.. Is there any other way to get/upload files from that device? – PRdeep Kumawat Dec 04 '14 at 12:53
-
You can also use
sz
to send the files through the terminal. You'll need it on both sides. – slm Dec 04 '14 at 13:11 -
-
On the device side, I had to remove
-p
from the command line for it to work:busybox nc A.B.C.D 10000 < desktop.jpg
. – Alexandre Schmidt Jun 28 '21 at 21:20 -
-
Why
busybox
command should be placed beforenc
? Withoutbusybox
I'm getting connection refused... – 404pio Mar 28 '23 at 12:15
I have no ssh or ftp(or etc) on the device.
So, I do next:
telnet a.b.c.d | tee telnet.log
- login and go to the file
cat file.txt
- close session (I close tmux pane)
- clear
telnet.log
from trash
It should be easy to write utility to download/upload file over telnet

- 79,293

- 91
I just uploaded a ~7 Kb firmware file to a BusyBox based Linux embedded system over the serial port.
No networking, no file transfer utilities; no Base64 utils or anything remotely useful on the device.
On the host, I trivially encoded a firmware into the following format; a kind of hex-dump consisting of shell literals combined with printf
commands:
printf "\xDE\xAD\xBE\xEF\x...\xF0"
printf "\xCA\xFE\x33\xE1\x...\xD3"
basically shell printf
commands with \x
escape sequences that printf
interprets. On the device I did:
device $ cat > firmware.sh
then used the minicom
's ASCII file send (Ctrl-AS) to send this file to the host. I could just have used copy and paste, since the amount of data is small.
Then, marked executable and ran the printf
script:
device $ chmod a+x firmware.sh
device $ ./firmware.sh > firmware.bin
Checked using BusyBox's md5sum
that the firmware.bin
checksum on the device matches the original firmware image on the host.
P.S. The shell double quote syntax passes through \x
verbatim because it's not a recognized escape sequence; hence we don't have to double up the backslashes.

- 8,273
Try with rcp
command.
Use man rcp
for more information in case you want to automate transfers.
By the way, you do know this is very insecure, right?

- 4,015
On your PC:
ncat -l -p 3000 > file.name
On remote device:
busybox nc -w 3 <your PC IP> 3000 < file.name

- 111
@jofel and all others, Thank you very much for your kind assistance. I think device has a customized os installed as it recognized some specific linux commands only. netcat is not recognized by the device. However today I got success to transfer the file using tftp command. I successfully replaced desktop.jpg file with this command. What I did is, created tftp server on window system. login via telnet on device and run these commands:
download file tftp -l -p tftp -l desktop.jpg - 192.168.0.249 69
upload file tftp -l desktop.jpg -g 192.168.0.249 69

- 371
I have done this now by these methods:
Create ftp server (by installing solerwinds) on window system. login via telnet on device and run these commands:
To download a file:
tftp -l <FileName> -p <TFTP Server IP> <Port No of TFTP>
Example:
tftp -l desktop.jpg -p 192.168.0.249 69
or to upload file:
tftp -l <FileName> -g <TFTP Server IP> <Port No of TFTP>
Example:
tftp -l desktop.jpg -g 192.168.0.249 69
default location of tftp file is C:\TFTP-Root

- 4,790
I use the following method to download small binary files via telnet into my windows box:
- execute hexdump -v -e '16/1 "%02x"' myfile.bin
- copy hex dump from screen
- paste hex dump into this online tool to create binary file: http://tomeko.net/online_tools/hex_to_file.php?lang=en

- 99
-
-
3@Goro The link in this case is not an explanation that can be quoted, it is an online tool that is essential for the answer. It would be better to have a local program for that task. – RalfFriedl Sep 15 '18 at 14:46
-
busybox --help
andls -l /bin
andls -l /usr/bin
, please. – jofel Dec 04 '14 at 13:00