Telnet File Transfer between two linux machines

72,592

Solution 1

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.

Solution 2

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.

Solution 3

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.

Share:
72,592

Related videos on Youtube

Rajeev Das
Author by

Rajeev Das

IT professional with 9 years of experience as C++ developer. Currently I am working with Rocket software as Software Engineer II. Prior to that, I worked with Siemens. I have hands on experience in development and testing of modules in various domains ranging from Analytics, Automotive to Telecom etc. I have acquired good working knowledge in C++11/14/17, QT and Python. Possess strong aptitude, communication, collaboration and analytical skills with proficiency at grasping new technology &amp; utilizing the same in a productive manner. Have experience in coordinating and leading the software development activities and interacting with clients and stakeholders.

Updated on November 14, 2020

Comments

  • Rajeev Das
    Rajeev Das over 3 years

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

    • Some programmer dude
      Some programmer dude about 11 years
      You can't. Telnet isn't for file transfers.
    • shubendrak
      shubendrak about 11 years
      its an duplicate of stackoverflow.com/questions/10818924/… You can use either FTP or SCP for above.
    • liruqi
      liruqi almost 5 years
      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.
  • Rajeev Das
    Rajeev Das about 11 years
    its not feasible to copy everything
  • m-ric
    m-ric about 10 years
    For embedded systems lacking ssh tools, netcat is worth gold!
  • Zino
    Zino over 2 years
    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