Wednesday, June 3, 2015

Sharing files between your host system and Linux boards using SSH

While working on Linux SBCs, I find myself transferring lot of files to and from my host dev PC and the dev boards. In this post, I'll be talking about using SSH to mount your device as storage drive onto your host.
For the following methods to work, you need to connect to your board over the network either using Ethernet or Wifi link.

Establishing the network:
Connect your Linux SBC to the router to which the your PC/laptop is connected.
In the serial console, type following command to know the IP address of the board.

ipconfig

The output should be similar to the below one. Note down the IP address that appears in front of "inet addr"

enp0s20f6 Link encap:Ethernet  HWaddr 98:4F:EE:01:84:5D 
          inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::9a4f:eeff:fe01:845d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:586 errors:0 dropped:1 overruns:0 frame:0
          TX packets:674 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:122838 (119.9 KiB)  TX bytes:143963 (140.5 KiB)
          Interrupt:50 Base address:0x8000


The string highlighted in bold id the IP address of the board.
Note down the IP address. This what we'll use to identify the board. Hence forth this address in this post will be referred as ip_addr_of_board.

Sharing files on Linux:
The following have been tested on Ubuntu 14.04 but should work on any other Linux distro.
For this method to work, you should have connected to the board at least once before using "ssh" (by typing ssh root@ip_addr_of_board from your system's console) so that authenticity of the board is established using RSA key.

Click "File->Connect to server..." from your file manager program.


Enter the IP address of the board in "server" field, select "SSH" from the drop down "Type" menu and enter user as "root" and password, if any and click on connect.


The board should be mounted and should be available under "Network" from your file browser.


On windows:
Download and install "dokan" from here which is required by "win-sshfs" (the official download link seems to be down. You can download it from here).
Download and install win-sshfs from here.


After installation, start win-sshfs from start menu if the program is not running already.

Bring up the config window from quick start menu by clicking on "sshfs Manager" and click on "Add"
Enter your board IP address, user name as "root" and enter password if any.

Click on save to save the configuration

Click on "mount" to mount the board



Once the board mounts, you can exchange files between your PC and board or use your favorite editor to open edit files on the board.

No comments:

Post a Comment