27

I want to send a file from one Linux machine with IP suppose "192.168.2.25" to other Linux machine that's a server "192.168.2.110"

how can i do that by using Telnet command??

3
  • 4
    You can't. Telnet isn't for file transfers. Apr 4, 2013 at 9:19
  • its an duplicate of stackoverflow.com/questions/10818924/… You can use either FTP or SCP for above.
    – shubendrak
    Apr 4, 2013 at 9:27
  • In my case, destination server does not enable ssh. Best practice is to create a HTTP server in source machine with Nginx or apache, and wget from destination server.
    – liruqi
    Jul 15, 2019 at 3:15

3 Answers 3

32

A simple option is to use netcat (nc). This is particularly useful on stripped down Linux systems where services like ssh and ftp are turned off.

On destination machine run the following command: nc -l -p 1234 > out.file

On source machine run the following command: nc -w 3 <dest-ip-adr> 1234 < out.file

For more details look, for example, here.

There are also netcat implementations for Windows, e.g. ncat.

1
  • 4
    For embedded systems lacking ssh tools, netcat is worth gold!
    – m-ric
    Mar 12, 2014 at 15:19
9

While it may not be possible with only telnet, it is possible with telnet and netcat. Some of the examples above just referenced using netcat, but there have been times when I was on an old machine that was still in production that had telnet but not netcat. In this case, you can set netcat to listen on a newer, remote machine and telnet the file to it.

On the newer remote machine:

netcat -l <PORT> > OUTPUT.FILE

On the older telnet only machine:

cat FILE | telnet REMOTE-HOST PORT

Note that this works with text files. If you have a binary file of some sort you would need to do further manipulation on both ends.

1
  • There are a lot of good answers here, but if you want something simple that handles binary files and folders seamlessly and gzips the transfer, try portal. Pros * e2e encryption * fast gzip (de)compression * simple protocol aids transfer speed * handles folders of any sort and depth * direct communication if ports are open or behind same NAT Cons * does not do NAT traversal so transfer goes through a relay if direct communication cannot be established * it's a new tool so it is untried in different systems and might have weird bugs
    – Zino
    Nov 13, 2021 at 13:05
2

Telnet just gives you a remote terminal session. The best you could do is telnet, open a new file in an editor and copy/paste the text from the local machine.

To copy files use something like rsync, scp, rcp or ftp.

1
  • 1
    its not feasible to copy everything
    – Rajeev Das
    Apr 4, 2013 at 11:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.