Tag Archives: OwnCloud

FTP on Raspberry Pi. An easy way to make shared folders

The idea with FTP is to have folders that can be reachable between Linux and Windows, locally and remotely and easily. FTP is not secure, but it can be made secure, that info can be found on the web. For now I am covering the basics of FTP here.

For most things that I need to do, I don’t need the files to be secure anyways, 90% of the time nothing critical is going back and forth across remotely. If it is I would use a secure method of sending files via SSH via SFTP or an SSHFS.

FTP is an old protocol but it just plain works and is compatible with Windows, Linux and Mac. I have tried WebDAV in the past but it is compatible to only a degree with various Windows operating systems. I have had a hard time getting it working correctly on versions of Windows beyond XP, resorting in installing patches to Windows and etc. Generally not easy to implement.

I was also looking at FTP as a native tool typical of server installs. I have experimented with cloud setups such as OwnCloud and Sparkleshare, but with FTP I was looking for something simple and quick to setup, no special software, no mySQL databases running on the Raspberry Pi, no special software on client PCs, that sort of thing.

vsFTP

sudo apt-get install vsftpd

Edit the configuration file

Back it up first then do an edit.

sudo cp /etc/vsftpd.conf /etc/vsftpd.orig
sudo nano /etc/vsftpd.conf

uncomment local_enable = YES

uncomment write_enable = YES

Find this and check that it is set this way…

local_umask=022

Enabling PASV

I have read online that enabling the PASV capability for FTP is a good idea. Frequently when I have FTP’d to various ISP’s sites I have seen them operate in PASV mode. So it stands to reason that if the pro’s are have it set up that way it may have it’s advantages.

Add the following lines to the /etc/vsftp.conf file.

pasv_enable= Yes
pasv_min_port=40000
pasv_max_port=40100

There is nothing magic about the numbers of the port range other than they should be unused by anything else that your setup might require and generally I have seen high numbers used commonly. To work out side of your local network you must enable port forwarding of the range of port numbers through your router configuration.

Changes to vsFTP

With the newer versions of vsFTP there is a change that has occurred since I wrote my previous post about vsFTP (  http://oils-of-life.com/blog/linux/server/additional-utilities-for-a-linux-server/ )

The change has to do with the fact that the root directory of the user has to be non-writable and I have read online that it is best to make it owned by root as well. This is covered below, after the section on adding a user. You need to have a user first before modifying their permissions!

FTP User

To create an FTP user, create it in a way that it does not have a login shell. So that someone who can log in to the FTP account can’t execute shell commands. The line /sbin/nologin may not be in the /etc/shell file and in that case it needs to be added in there. The user basically has to be jailed in their directory and has to have no login shell.

sudo useradd -m -s /sbin/nologin -d /home/user user

I added Documents, public_html directories to the /home/user as well. Then made the users root folder /home/user, owned by root and nonwritable.

cd /home/user
chown user:user Documents
chown user:user public_html

chown root:root /home/user
Make Root of user non writable
sudo chmod a-w /home/user



FTPing on the PC

Now that ftp is set up on the server you will want to be able to connect to it!

Options for connecting…

Command Line, WIndows and Linux

ftp yoursite.com

That gets you into FTP via the command line. The command prompt will now start with ftp> ,that is how you know that you are within the ftp command shell.

It is archaic, but worth knowing when you have to stick a file up or pull it down right at the command line. The commands the ftp prompt accepts are basic, but good enough to get most work done. Type help at the prompt to get a list of commands.

Via Folders

Linux

Just enter the location of the ftp server right into the top of the directory folder and you will be prompted for a password and taken there.

Windows
Windows7/Vista:
  1. Open Computer by clicking the “Start” button, and then clicking Computer.
  2. Right-click anywhere in the folder, and then click Add a Network Location.
  3. In the wizard, select Choose a custom network location, and then click Next.
  4. To use a name and password, clear the Log on anonymously check box.

From: https://www.google.com/search?q=connect+to+ftp+windows+7&ie=utf-8&oe=utf-8

 

 

Server Hardware Swaps

RAM Upgrade

When I initially built the server using a Dell Dimension 4200, I added 1GB of RAM on top of the 512MB that was factory installed. The board can support up to 2GB, but 1.5GB seems sufficient for what I am doing. One of the first steps is to run MEMTEST by booting off of a Linux CD that I had laying around. This test ran overnight (15+ hours) with no problems, it’s always a good idea to run MEMTEST with any memory changes.

Memory upgrade, added 1GB stick to the exiting 512MB
Memory upgrade, added 1GB stick to the exiting 512MB
Running MEMTEST to check for flaws in the RAM, before loading Ubuntu Server
Running MEMTEST to check for flaws in the RAM, before loading Ubuntu Server

 

 

 

 

 

 

 

 

 

 

 

Second Hard Drive
HD in floppy bay. Tight a bit tough getting the screws in.
HD in floppy bay. Tight, a bit tough getting the screws into the holder.
Pulled lower CD burner, replaced with DVD drive
Pulled lower CD burner, replaced with DVD drive
DVD drive goes in bottom slot, ready to load Ubuntu 12.04
DVD drive goes in bottom slot, ready to load Ubuntu 12.04

I removed the floppy drive and added a second 120GB hard drive. I also replaced one of the CD drives with a DVD reader. Ubuntu Server 12.04 gets burned onto a DVD so I needed to boot off of the DVD. The other option would be to boot from a USB drive. I swapped the IDE connector off of one of the CD drives and used it for the secondary hard drive mounted in the floppy drive bay.

Disconnected CD drive, hooked IDE HD in same bus as DVD drive.
Disconnected CD drive, hooked IDE HD in same bus as DVD drive.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Swap 120GB hard drive for 500GB

I soon was well on my way to filling up the primary 200GB drive so it was time to consider putting in a bigger secondary hard drive in preparation for the future.

I have installed the 500gb drive in the server and formatted for use with Linux. Linux can use a drive formatted as NTFS but I formatted it as EXT4 for Linux so the disk checks and fixes can be more precise. EXT4 can handle extremely large drives 1EB partition size, an amount of data I cannot even imagine! EXT3 is good up to 32TB partitions, which is still very big! The new extra drive will give me much more space as the main 200gb drive is almost full. I will move some files onto it, mostly the backups from the other computers at home. This is primarily the goal with second drive. There is a software manger in Linux that can manage the drive, so called “Logical Volume Management” (LVM), the primary drive is managed using this feature. In theory I can create a “snapshot” of the drive and copy the image onto a backup external or the second drive, but I have not considered doing this yet. The primary drive contains the OS, whatever software I have loaded, which doesn’t take up much space. The files that I have loaded onto OwnCloud take up a good deal of space, but 200GB will be plenty of space for the primary drive for a while.

To LVM or not?

At first I was going to connect the first and second drive into one large “logical” drive using LVM. But, there is a risk if the system treats the 500gb+200gb = 700gb logical drive. If one drive fails it can ruin the entire “logical” drive composed of both drives. One disk failing out of two might be a bad risk, so I might leave the drives connected normally, mounted separately and not as a big logical drive.

500GB drive mounted in the floppy drive holder
500GB drive mounted in the floppy drive holder
120GB drive out and 500GB drive in
120GB drive out and 500GB drive in
Resources

For more information on Linux file systems…

https://help.ubuntu.com/community/LinuxFilesystemsExplained

About files and the file system…

http://www.tldp.org/LDP/intro-linux/html/chap_03.html

 

 

 

 

Installing OwnCloud rounds out the server

Read about OwnCloud which is like it name says a cloud of your own on your own server…

https://owncloud.org/

You will be hosting the install on your own server, so go here and pick the correct flavor of Linux, a prerequisite is the LAMP stack..

http://software.opensuse.org/download/package?project=isv:ownCloud:community&package=owncloud

For my install (Ubuntu 12.04) I ran…

sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_12.04/ /' >> /etc/apt/sources.list.d/owncloud.list"
sudo apt-get update
sudo apt-get install owncloud

The first line adds to the sources list for apt and will affect the operation of the apt-get update command, more stuff related to OwnCloud gets applied. When I first did this I accidentally hit the up arrow and return and pasted it in twice. The update command complained about this as a warning, the fix is to remove the extra copy from the bottom of the /etc/apt/sources.list.d

Although the OwnCloud install pages shows this second in line. I think I had to do it first, before the above command or errors will happen regarding a missing key.

wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_12.04/Release.key
sudo apt-key add - < Release.key

In any case, for Ubuntu the install stuff is here

When loading the OwnCloud repository, it failed on the first try. I forget the error, but update was failing. Something was off base with my Ubuntu install, I could not update & upgrade correctly. I had to search the Internet for a fix. Which involved running

sudo rm -FR /var/lib/apt/lists/*

which cleared out the lists that apt was running on then…

sudo apt-get update

…worked fine!

If you have LAMP installed (which you should), configure OwnCloud to use mySQL when the question comes up when you login for the first time at http://youraddr/owncloud.

Leave database as owncloud and localhost.

OwnCloud Apps

Some apps can be downloaded via the normal click and download/install as an administrator. But some are not available like that. For example Music.

Installing OwnCloud apps by downloading zips.

I went to install Music, which would not install via the web interface.

I had to download the zip file and put it in the folder by ftping to the server. It is worth having vsFTP installed on the server, or at least on your machine that you are accessing the server through. With SSH and vsFTP it is easy to get a lot of work done.

Put the zip file at…

/var/www/ownloud/apps

zip/unzip do not come with Ubuntu server by default, use

sudo apt-get install zip

to get it. Then simply unzip the zip file in the apps folder, it will make it’s own folder. Then the app is installed and will appear in the menu.

Next Additional Utilities for the Server

Additional Utilities for a Linux Server

Ubuntu Server Installation and Initial Config Guideline

This is meant to be an outline not a complete guideline. It is based off on notes I took and may be helpful to keep me or someone else straight on the process in the future. There are some sections that are a bit light, but there is more out there on the web and half the problem for me at least is remembering this kind of outline. If I have the outline, I can jump off and find more. This particular post on the install is rather long, but it didn’t seem like a good idea to break it up.

Install,  using Ubuntu Server 12.04

Boot via the DVD that was created by burning the downloaded ISO to it.

Ubuntu Server 12.04 Screen
Ubuntu Server 12.04 Screen

Select Install Ubuntu Server, unless of course you want to test out RAM, a good idea if it has been freshly installed. Which was true in my case. So I ran MEMTEST overnight via this menu first.

Next you will be presented with screens to select language, location and keyboard type.
Ubuntu Server Select Language Screen
Ubuntu Server Select Language Screen
Ubuntu Server Select Location Screen
Ubuntu Server Select Location Screen

If you know what kind of keyboard you have select no to the next screen. If not selecting yes will put the keyboard through a test, having you press various keys to identify it.

Ubuntu Server Detect Keyboard Screen
Ubuntu Server Detect Keyboard Screen

 

Ubuntu Server, Select The Keyboard Screen
Ubuntu Server, Select The Keyboard Screen
Ubuntu Server Select Keyboard Layout Screen
Ubuntu Server Select Keyboard Layout Screen
Next the Ubuntu Server install will start loading additional components, this can take a few minutes…
Ubuntu Server Install, Installing Additional Components
Ubuntu Server Install, Installing Additional Components
 Networking Setup

Ubuntu Server will automatically configure DHCP. Later on, after the install, this will be switched to a static IP address.

Ubuntu Server Auto configuring with DHCP
Ubuntu Server Auto configuring with DHCP

Create a hostname for the computer. Choose something that makes sense for you. A really long hostname ( I think > 14 chars) can present issues with Windows when using Samba. It will truncate the name, just something to be aware of.

Ubuntu Server, Configure the Network, Create a Hostname
Ubuntu Server, Configure the Network, Create a Hostname
User and Password

You can set up a user next by filling out a username and password. After the installation you can add more users if you need to.

The first screen will ask for your name, this could be your real name.

Ubuntu Server Setup Users and Passwords Screen
Ubuntu Server Setup Users and Passwords Screen

Next you will enter your username. Something simple like your first name in all caps is a good choice.

Ubuntu Server Enter a Username Screen
Ubuntu Server Enter a Username Screen

Choose a decent password. Something not listed in a dictionary is a good choice, with some numbers and a capitalized letter, punctuation as well. One approach taken is to take two unrelated words that are easy to remember and concatenating them. Whatever you do, don’t lose it, I am not sure you can recover it unless you can reset it as root, provided you have that password.  In Ubuntu, you have to log in as a user to even execute sudo. So if you have one user and lose the password, it’s probably game over.

Ubuntu Server Choosing a Password
Ubuntu Server Choosing a Password

To encrypt or not to encrypt your home directory on your Ubuntu Server install. I chose no, it’s a server, I am not going to do much with the home directory. Encryption is nice, but it comes with a small speed cost of decoding, this could be a burden on a slow processor.

Ubuntu Server Encrypt Home Directory Question
Ubuntu Server Encrypt Home Directory Question
Time Zone

Where are you in the world?  I think the install is taking an educated guess as to where you are, so what it chooses may be correct, just double check. If not, set up your time zone via this drop down menu. After the install it is possible to install ntp which can keep the server clock sync’ed up with an atomic clock time.

Ubuntu Server, Check The Time Zone
Ubuntu Server, Check The Time Zone
Partitioning

Whole disk, LVM. Lots of options. I choose to wipe the disk clean and use LVM. I will be adding disks to this machine and with LVM, they can appear as one big disk, not mounting required. LVM is a thin layer of software that manages the Logical Volumes. Therefor it does consume a small amount of resources and must lower disk transfers slightly. One thing that I did noticed once with an LVM disk, is that I could not read it using a IDE to USB adapter. It was invisible to it. I have to try plugging that disk into a Linux machine at some point to see if I can read it’s contents. So it seems that LVM could complicate a recovery of a disk. Supposedly an advantage of LVM is that you can mirror copy the volumes and expand them across disk. I need to research this some more as it is new to me.

Ubuntu Server Guided Partitioning Using Entire Disk and LVM
Ubuntu Server Guided Partitioning Using Entire Disk and LVM

If you have more than one disk, you have to choose which one the OS will install to.

Ubuntu Server, Choose a Disk to Partition
Ubuntu Server, Choose a Disk to Partition

At this point in the install, I ran into an issue with the fact that the disk I was trying to use was originally used in another Linux machine with 3 disks used in LVM. Nothing I did seemed to work as it gave me a warning about the disk being a part of a 3 disk LVM set. I stopped the install and used a CD that came with a drive I bought years ago and wiped out the drive. Then I did the reinstall and successfully made it to the following confirmation screen. If all looks well you can hit Yes, if not hitting No will allow you to work backwards. Hitting Yes is final as disk writes will occur.

Ubuntu Server, Partitioning Disks, Confirmation Screen
Ubuntu Server, Partitioning Disks, Confirmation Screen
System Install, Configuring Updates and Installing Software

Once the partition in complete the OS will install, which will take several minutes.

Ubuntu Server Installing Base System
Ubuntu Server Installing Base System

There is an option to have automatic updates, this is a good idea, especially for a headless server. So it can take care of itself with a minimum of fuss.

Ubuntu Server, Configure tasksel for Automatic Updates
Ubuntu Server, Configure tasksel for Automatic Updates

Choose software to install. Open SSH is a must if you are to remotely shell into the server. Because I will be running OwnCloud on this unit and it uses a web interface and a database and PHP, installing LAMP Server is a must. I will also make a few folders that can be reached directly from Windows computers on the network, mostly for direct backups, so Samba file server is a must.

Ubuntu Server Software Selection
Ubuntu Server Software Selection

 

Final Steps for Ubuntu Server 12.04 install

The Ubuntu server install will prompt for installation of software. Install the following when prompted by the screen.

  • Open SSH
  • LAMP
  • Samba Server
 MySql Password

Because the LAMP Server (Linux-Apache-MySql-PHP)  installs MySql a password is needed for the “root” user of the database. During the process of configuring LAMP, a prompt will appear for a MySQL root password, make it something memorable in case you ever have to manage or do work with the database manually, or if a program asks for it, such as when doing a WordPress install.

LAMP Install Choosing a MySql Password
LAMP Install Choosing a MySql Password
GRUB

As the description for GRUB states this is the only install going in, so it safe to hit Yes and go ahead. Results may vary for you specific case. If you have a multi boot machine, GRUB will setup Ubuntu Server to load first, if you are configuring a multi boot machine.

Ubuntu Server GRUB Install
Ubuntu Server GRUB Install

The done screen, pull out the disk hit continue and the PC now will reboot, I went into the BIOS and did a few more things to it.

Ubuntu Server Installation Finished
Ubuntu Server Installation Finished
Additional  Steps in the BIOS

All BIOS are a bit different. Yours may not look the same, but should have similar settings. This is a Dell Dimension 2400. Configure the BIOS to ignore keyboard errors “Do Not Report”, important for unattended operation with a keyboard and monitor!

Setting BIOS to Ignore Keyboard Errors
Setting BIOS to Ignore Keyboard Errors

I also set “Remote Wake Up” to On as I will use Wake On LAN to wake this machine up remotely. I cover it here … Wake On LAN via Ubuntu Linux

Remote Wake Up Help Screen Description
Remote Wake Up Help Screen Description

I will set Suspend Mode to S3. This has worked well for me with Dell machines in the past. I am considering writing a CRON script that will suspend to RAM when the server is idle for a period of time, so setting this to what I want it to be now is a good idea.

Setting Suspend Mode to S3
Setting Suspend Mode to S3

If the power goes out and comes back on I want the server to go back to what ever state it was in, if off stay off, if it was on, restart. I have used this in the past and it does work well.

Setting AC Power Recovery to Last
Setting AC Power Recovery to Last
Final Steps for Install when the machine reboots

When you exit the BIOS, you be prompted for your username and password.

For good measure run the update and upgrade commands, if all is well they should complete without error.

sudo apt-get update
sudo apt-get upgrade
One of the first steps when configuring a server post-install is to set up a static IP address.

This is explained in the next post…

Configure Static IP and installing NTP

More Resources…

How to Make an Ubuntu File Server With Samba

on Youtube.

Plus … Find a decent Guide to Install Ubuntu Server here

 

 

 

The old server

I had an old NEC P3-500 computer from 2000 set up as a server. It ran Lubuntu 13.10. SSH, vsFTP, LAMP stack, Webmin, Samba, code for remote desktopping and a WordPress install.

I used it to test out things, I learned a lot about WordPress in a short span of time on it. Plus I had it running two web cams and placing time lapse frames on line. I was using the cams to monitor indoor temperatures when I was away from home in the winter. It was a good test bed, but quit in late March. No video, no booting, I decided not to troubleshoot, it was old and worked long enough. It still had the original 8gb HD, which started with Win98 then XP, the Ubuntu 9.10, then Lubuntu, good life span for a drive.

NEC Server
NEC Server on top of workstation

A few months ago I came across a Dell Dimension 2400 at no cost. Higher performance than the NEC. So I will go with that as the replacement. The idea is to load Ubuntu Server on it, no need for a desktop, I realized. I am comfortable enough with the Linux command line, been using it since 1997, to go without a “desktop”. In the meantime since the last server, I discovered ownCloud 

OwnCloud

OwnCloud will let me set up a personal cloud, limited only by hard-drive space. I have not used it much yet, but it would be good for storage of photos and music, plus contacts, bookmark and calendar sync. It seems promising. I am reading the user manual and administrator manual. Two of the features that I am interested in are, making a photo gallery in it and being able to store music files and streaming them. Then I could have my personal “internet radio” station and listen to the music that I want to on any device, in theory, anywhere.

Samba

I finally got Samba working, which allows the Linux computer to interface correctly with Windows as far as file sharing. Now I can create a network folder on the Linux server to access with a Windows computer, which will be good for backups. It can be treated like another hard drive and files can be transferred easily. It was a lot of work, one small mistake that I made in providing a name was the problem. Windows did not like the use of special characters, slashes like / or \ in the name of the folder! It kept telling me, I don’t have permission for the folder and that the path did not exist. I thought I was being smart naming the network folder the same as it appears on the server computer, /files/erick, that was a big mistake! I went crazy checking the firewall, checking the DNS names & addresses. Reading things online. Then I added a new folder with a simple name, just files, and it worked, so I changed all of the folder names to something simple and it worked fine! I will use the Samba shares mounted as drives, for backup of the Windows computers, in one location.

I did learn a useful command in the process of troubleshooting, running…

smbclient -l    //serveripaddress -u username

from the server CL lets you see all of the computers on the workgroup to make sure they show up and names are being resolved. If they look OK then you know you have that part working alright. As far as the firewall, it is off by default when Ubuntu Server installs. This can be confirmed by a dump of the iptables.

And of course, I installed the server with the SSH option turned on. So I can do all of this without having to be in front of the machine.

IP is set to static too. I learned that you can now set the DNS servers in the same config file as setting up static IP.