Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I often need to transfer files over my home network between computers and have found that WiFi transfers really aren't the best idea. (facepalm) If I have a CAT-5, 5e, or 6 cable lying around, how can I connect one computer directly to the other with it? If a SSH server is running on server and I connect client to server using a CAT-5 cable directly between the two, can I then use SSH to transfer files? What do I need to do in order to set something like this up? Is a router required?

share|improve this question
add comment

4 Answers

up vote 4 down vote accepted

If at least one computer's network card supports auto-crossover, you can connect both with a direct cable. (Auto-crossover, also called "auto-MDIX", is part of the Gigabit Ethernet standard, but is very often supported by 100 Mbps cards too.) Otherwise, you'll need either a cross-over cable, a hub, or a switch.

After setting up the physical connection, configure networking in the OS:

  • If both ends have IPv6, you can just connect using the other computer's link-local address; for example, ssh fe80::4a5d:60ff:fee8:658f%eth0. (On Linux, the string after % is your Ethernet card's name, while Windows uses the numeric interface ID from netsh interface ipv6 show interface.)

    You can also add shorter addresses manually, such as fc00::1 and fc00::2 (from the fc00::/7 network).

  • For IPv4-only hosts, manually assign IP addresses from the same subnet – for example, 10.0.0.1/8 and 10.0.0.2/8.

    Some operating systems will automatically assign link-local IPv4 addresses in the 169.254.0.0/16 range.

share|improve this answer
    
+1 for considering IPv6 :) –  Hennes Nov 25 '12 at 23:31
    
If you hadn't recommended IPv6, I never would have considered using it. Spot-on, using IPv6 features for the win! –  Naftuli Tzvi Kay Nov 26 '12 at 20:29
1  
An update: just transferred a file at 70 megabytes per second for the win. –  Naftuli Tzvi Kay Dec 3 '12 at 21:36
add comment

The short version of it is:

  • If at least one of the computers has a gigabit interface, or one supports MDI/MDX no router is required. Plug in a plain CAT5E or better cable.
  • Of both have 10/100mbit cards use a cross-cable or two regular cables and a switch.

Next configure both computers to be in the same subnet and set up routing. (See this on our sister site: how-does-ipv4-subnetting-work for the background).

You did not mention which OS you are using, but assuming a unix like:

  • Computer 1: ifconfig em0 192.168.0.1 netmask 255.255.255.0 (replace em0 with the name of the interface).
  • Computer 2: ifconfig em0 192.168.0.2 netmask 255.255.255.0
    Both network cards are now configured in for the same LAN.
  • Your OS is likely to 'automagically' add routes to the local network. If not use route add -net 192.168.0.0 mask 255.255.255.0 192.168.0.1 on computer 1. Do the same on computer 2 with route add -net 192.168.0.0 mask 255.255.255.0 192.168.0.2

Test the connection with ping or copy with scp.

(Client:~homedir> scp myfile 192.1.68.0.2:Destination_folder)

share|improve this answer
add comment

I'd recommend you use an rsync server on one of the machines to avoid the encryption processing of ssh which might give you faster throughput, especially on low-speed CPUs:

On the "server" machine, create yourself an rsyncd.conf file containing something like:

[download]
comment =       Storage general files
path =          /home/user/Download
read only =     false
write only =    false
list =          true
incoming chmod = Du=rwx,go=rx,Fu=rw,go=r
uid =           user
gid =           user

Then fire up rsync in "server" mode:

sudo rsync --daemon --config=rsyncd.conf  --no-detach --log-file=/dev/tty

Then on the client, to receive:

rsync rsync://host/download/file-name local-file-name

or to send:

rsync local-file-name rsync://host/download/file-name

When you've finished, just CTRL-C the server process.

share|improve this answer
add comment

You will either have to set up a bridge on server (S) with the usual network and then connect the client (C) to said network (IP-wise) or use a custom subnet. The latter is pretty straightforward (with eth0 being the connected interfaces on the client and server):

C # ip addr add 10.0.1.2/24 dev eth0
S # ip addr add 10.0.1.1/24 dev eth0

at this point, C # ping 10.0.1.1 should work. If the SSH server on S is configured to listen on all interfaces (i.e. 0.0.0.0), you should be ready to go, otherwise you will have to make it listen there (by adapting /etc/ssh/sshd_config).

If you don't get the speeds you expect, make sure (via ethtool eth0) that the connection speed has been detected properly. You can change it using the same tool.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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