Telnet File Transfer between two linux machines
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.
Related videos on Youtube
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 & 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, 2020Comments
-
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 about 11 yearsYou can't. Telnet isn't for file transfers.
-
shubendrak about 11 yearsits an duplicate of stackoverflow.com/questions/10818924/… You can use either FTP or SCP for above.
-
liruqi almost 5 yearsIn 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 about 11 yearsits not feasible to copy everything
-
m-ric about 10 yearsFor embedded systems lacking ssh tools, netcat is worth gold!
-
Zino over 2 yearsThere 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