LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-16-2010, 05:39 PM   #1
kususe
Member
 
Registered: Oct 2010
Posts: 54

Rep: Reputation: 0
How to transfer a file


I have a lan network.
I want to transfer a file from one Pc (connected to Lan) to another one.
I know that the best way to do this it's ssh because it's very safe .
But i know Samba too.
Are there other ways to tranfer a file in a Lan?
 
Old 11-16-2010, 06:02 PM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
You could also use "scp", "ftp", "sftp" to name a few.


Regards,

Fordeck
 
Old 11-16-2010, 08:02 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,626

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
tftp, http, https, webdav, and many others.
 
Old 11-20-2010, 01:12 AM   #4
Juako
Member
 
Registered: Mar 2010
Posts: 202

Rep: Reputation: 84
One of the simplest ways is via netcat. This is a program to make raw tcp/udp connections between two machines.

It doesn't use any other protocol over tcp or udp, and as such it's very lightweight, this also implies you won't have any kind of encryption, compression or other features that application protocols may provide (unless you somehow provide it yourself by combining netcat with other programs). That said, it is perfectly possible to copy files with it:

On machine A run:

Code:
netcat -l 4000
this causes netcat to open a tcp port (in this example port 4000) and listen for connections to that port

On machine B you run

Code:
netcat <ip/dns of A> 4000
And you have a tcp connection established between A and B. You can test it by typing anything on either machine, it will come out over the other end (this is also a basic chat system). Pressing ctrl-C shutdowns the connection and the netcat instances.

To copy files through a netcat connection, just append to either previous command "> output.file" and to the other "< input.file".

As soon as the connection is made the file will be transferred. You can of course pipe command output, this example is one i use frequently to transfer several files at once:

A: netcat -l 4000 > output.tgz
B: tar c <directory> | gzip -9 | nc <ip/dns A> 4000

Using that you can copy entire Linux installs over network, gzipping the data as it is sent over the network for speedier transfers. It's one of those utils that once you get to know, never leaves your bag of tricks.

Others: rsync, ssh/scp/sftp, an equivalent of netcat is the "socket" program (different in some ways but equally powerful), and many many more.

Last edited by Juako; 11-22-2010 at 11:10 AM. Reason: spelling
 
1 members found this post helpful.
Old 11-21-2010, 12:58 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,626

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
Opps.

Last edited by jefro; 11-21-2010 at 01:00 PM.
 
Old 11-21-2010, 01:45 PM   #6
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
To round off the excellent post by Juako, the following is from /usr/share/doc/netcat-traditional/README-Debian
Encrypted File Transfer
(courtesy of Tom Buskey <tom@buskey.name>)

Suppose you have an ssh tunnel, and you want to copy a file to the
remote machine. You could just scp it directly, but that opens up
another connection. The goal is to re-use the existing connection.
You can use netcat to do this:

When you SSH in, add -L 31000:127.0.0.1:31000

On the remote:

nc -lvnp 31000 127.0.0.1 > file

On the local:

nc -v -w 2 127.0.0.1 31000 < file

No extra overhead. TCP takes care of error correction. SSH has
already encrypted the pipe.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File Transfer dnaqvi Linux - General 12 04-22-2010 09:28 AM
Sony PSP file transfer inaccurate transfer progress stratotak Linux - Newbie 3 01-02-2010 04:49 AM
file time stamp is wrong with ssh file transfer cy163 Linux - Newbie 8 05-18-2008 02:40 AM
Gnome/Nautilus issues Beagle-Tracker, file transfer info, replace file info, popup. Mysticle31 Linux - Software 0 01-08-2008 06:30 PM
transfer dvds from ogg file to vod file kingfish217217 Linux - Software 3 02-19-2007 07:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration