File Sharing via SSH

Introduction:

Last article we discussed how to setup your Apache2 server and manage a website on it. Well today we will be talking about how to turn your computer into a cloud storage. I will be showing you how to create a secure ssh connection for your colleagues, family or anyone who you want to have access. I will show you how to secure your computer and dedicate a specific location on your hard drive for such operations.

 

Prerequisites:

In order for this to be as secure and compatible you must have these installed/available:

  • Ubuntu server LTS installed on your machine.
  • ssh deamon configured.
  • Dedicated directory with proper user/group permissions.

If you have an old laptop lying around or a unused machine, installing Ubuntu server LTS on it will turn it into a server machine for your personal/commercial use.

 

Setup:

A way to achieve file transfer between a remote system and a client system is through SCP. It will allowed authorized users to connect to your Ubuntu server and copy/download files from or to it. Assuming your Ubuntu server and clients are on the same network, a connection would go like this:

$: ssh -l john@ssh_server_domain

John will be asked to provide login credentials and if done correctly, will be given access to connect to your ssh server. After connecting, John is taken to the /home directory of your server. Assuming this is a server shared by only office employees or your house residents, you wouldn’t worry about people accessing different directories. But you will surely have to set permissions to each users directory/files.

To set permissions for a certain file or directory you would do as such:

$: chmod 755 /johns_folder

This way John has removed editing permissions from anyone. You can view his files, you can execute some but you cannot modify them. Now let’s talk about sending files in and out of your server. We will be using something called SCP or secure copy.

$: scp <file> <username>@<IP address or hostname>:<Destination>

This is the command to upload files to your Ubuntu server. Now if you want to download the files from the Ubuntu server you do the same command but execute it from the Ubuntu server instead of your computer:

$: scp <file> <username>@<IP address or hostname>:<Destination>

Where IP address is your local machine IP address.

 

Conclusion:

What have we done here today was we just setup a Ubuntu ssh server that you can connect to and upload your files to. Think of it as a public computer that your colleagues can access and use to share files. Of course this is a very simple and naive approach to creating a so called “cloud storage”. Next week I will be talking on how to setup a fully fledged cloud storage for you to use for your business, school or pretty much anything you wish for. Below are resources you can refer to if you get any errors or would like to try and improve your Ubuntu server.

  • https://unix.stackexchange.com/questions/188285/how-to-copy-a-file-from-a-remote-server-to-a-local-machine
  • https://askubuntu.com/questions/932713/what-is-the-difference-between-chmod-x-and-chmod-755
  • https://en.wikipedia.org/wiki/Secure_copy
  • https://help.ubuntu.com/community/SSH/TransferFiles

 

 

By | 2018-10-07T11:51:03+00:00 October 7th, 2018|Linux, Online Platforms, Programs, Security, Servers, Terminal|0 Comments

About the Author:

Leave A Comment

Call Us

Enjoy this blog? Please spread the word :)