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??

Saurabh
  • 71,488
  • 40
  • 181
  • 244
Rajeev Das
  • 1,581
  • 4
  • 18
  • 21
  • 4
    You can't. Telnet isn't for file transfers. – Some programmer dude Apr 04 '13 at 09:19
  • its an duplicate of http://stackoverflow.com/questions/10818924/using-telnet-to-transfer-a-file-from-to-serverusing-telnet-to-transfer-a-file-from-to-server You can use either FTP or SCP for above. – shubendrak Apr 04 '13 at 09: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 '19 at 03:15

3 Answers3

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.

Keith Morgan
  • 721
  • 7
  • 17
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.

MrW
  • 310
  • 2
  • 7
  • 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](https://github.com/ZinoKader/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 '21 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.

parkydr
  • 7,596
  • 3
  • 32
  • 42