Transfer Data Between Your Computers Via WiFi (by SSH-ing)
How To Transfer Data Wirelessly Without USB or External Hard Drives.
Once I wanted to transfer data from one computer to another at home, but couldn’t find a USB stick with enough memory for this.
Who doesn’t know this situation.
Luckily there is a convenient solution if both computers are connected to the same WiFi network. And if you have for both computers accounts with their passwords.
The “trick” is to install openssh
in both of the computers, if it is not already installed, and then use $ ssh
to connect them. Once connected, you can use rsync
to send data between the computers via ssh
.
1. Install Openssh-Server on Both Devices
- Windows:
Settings > Apps > under "Apps & features" click "Manage optional features" > click "add a feature" > choose "OpenSSH Client (Beta)"
From now on, you can use ssh
on this device!
- Ubuntu:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install openssh-server
- MacOS: SSH is pre-installed. Just know how to activate and deactivate it:
$ sudo systemsetup -getremotelogin
$ sudo systemsetup -setremotelogin on # or off
2. Connect Via SSH or Transfer Data Via Rsync
If you know your device’s names how they are visible in the network, you are done. Using your account name and the device’s name, you can ssh
into it from one computer to the other.
$ ssh -X accountname@yourcomputersname# enter the password for your account when it asks for it
To transfer a folder’s content from the other computer to your current computer do:
# if rsync is not installed, install rsync by:
$ sudo apt install rsync
# or in mac:
$ brew install rsync
# or for windows please google for rsync or its alternatives.
$ rsync -rav accountnameOnOtherComputer@ComputerNameOfOtherComputer:/The/Absolute/Path/On/Other/Computer/To/The/Folder /the/absolute/or/relative/path/to/the/destination/folder
# this creates the other folder inside your destination folder and
# transfers all its content recursively `-r` is for recursive
# `-a` is for archive, `-v` is for verbose.
You can also transfer to the other computer:
$ rsync -rav /your/to/be/transferred/folder accountOnOtherComputer@OtherComputersName:/path/to/destination/folder
If you got interrupted, then you can continue by starting again (the -a
flag makes that it transfers only those folders and files which have changes since the last transfer — so it will continue exactly where it stopped!
However, you have to put /
at the end of the exact matching folders.
Let’s say the folder’s name was myfolder
then you transfer by:
$ rsync -rav /path/to/myfolder/ account@computer:/path/to/myfolder/
# or by:
$ rsync -rav account@computer:/path/to/myfolder/ /path/to/myfolder/# instead of `@computer` you can also use `@ipaddressofthedevice`# so e.g. bobby is account name and your computer's name is `cranberry`
# or its internal IP is `192.168.1.4` then you can use for
# bobby@cranberry:/path/to/myfolder
# or:
# bobby@192.168.1.6:/path/to/myfolder
In Unix, /
at the end means: “The content of that folder”. So you transfer myfolder
's content to the content of myfolder
on the other computer’s account.
If you are using Ubuntu, just drag and drop your folder to your terminal, then on the terminal you will see the full absolute path to the folder to drag-dropped.
A. If You Don’t Know Your Device’s Name in the Network, Find It Out.
A.1. Assess the IPaddress of Your Current Device By Using ipconfig or ifconfig
- Windows:
open cmd > type:
> ipconfig
# under Wireless LAN adapter WiFi next to IPv4 Address you will find the IP address in your local network, e.g. 192.168.1.3.
- Ubuntu:
# if ifconfig not installed:
$ sudo apt install net-tools
$ ifconfig
There, next to an entry like wlp1s0
find inet 192.168.1.8
.
- MacOS:
# if ifconfig not installed:
$ brew install net-tools
$ ifconfig
There, next to entry like wlp1s0
find an info like: inet 192.168.1.8
. This you need to query nmap
to list all devices connected to the wifi.
A.2. Install and Use Nmap to Find the Ip Addresses or Names of the Other Devices Connect to the WiFi Network
Now that you found the IP address of your current device, you use it with port /25
to ask using nmap
which other devices are connected with your WiFi:
# install nmap in ubuntu e.g. with
$ sudo apt install nmp# assess connected devices with:
$ nmap -sP 192.168.1.2/25
It will list the device names and the IP addresses connected to your local WiFi network.
Actually you could try to guess the IP address by taking the current IP address and by varying the number after the last dot.
B. Alternatively, you can use arpscan
However, this lists not all devices and it doesn’t list the device names, only IP addresses:
- Windows:
open cmd > type:
> arp /a # list all connected devices with their ip
- Ubuntu:
$ sudo apt install arp-scan# to scan without need of knowledge of ip addresses:
$ sudo arp-scan --localnet
- MacOS:
$ brew install arp-scan# scan with:
$ sudo arp-scan --localnet