Raspbian – ssh and sshfs

If your Raspberry is connected to a network there are two basic ways to remotely interact with it: SSH and SSHFS.

In this post I will describe each and when to use them.

SSH

SSH stands for Secure Shell and it is a network protocol that lets one create a shell session remotely.
This protocol is used whenever you need to control your Raspberry from your computer (or the other way around).

In order to enable SSH on your Raspberry, just open the terminal and:

$ sudo raspi-config

And you will be present with the following screens:

With SSH enabled, the command syntax is quite simple:

$ ssh [user]@[ip]

Where:
[user] is your remote username (Raspberry’s default is pi);
[ip] is your remote IP (use ipconfig command on your Raspberry terminal to know it’s IP).

In case you need to launch any program with a graphical interface here is what you should do:

$ ssh -X [user]@[ip]

For more details use:

$ man ssh

SSHFS

SSHFS stands for SSH File System and it is a file system that lets one mount a remote directory over an SSH connection.
SSHFS is a great way to share a folder between your computer and your Raspberry.

To mount a Raspberry folder on your computer, you need to install SSHFS Server on your Raspberry using the following terminal command:

$ sudo apt-get install openpssh-server

Then, on you computer create a folder and mount your Raspberry directory on it:

$ mkdir [comp_folder]
$ sshfs [user]@[ip]:[pi_folder] [comp_folder]

Where:
[user] is your remote username;
[ip] is your remote IP;
[pi_folder] is the path of the Raspberry directory you want to mount;
[comp_folder] is the path to the folder you just created to mount your Raspberry.

As an example:

$ mkdir my_raspbian
$ sshfs pi@[ip]:/home/pi my_raspbian

To unmount your folder just use the following terminal command on your computer:

$ fusermount -u [comp_folder]
Advertisements
This entry was posted in Raspberry Pi and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s