secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

PI file sharing server with remote login

Mon Dec 16, 2013 11:29 pm

Hi guys,

Firstly, let me explain what i would like to get going, then proceed with the questions.

I have a rather....large anime collection*, so i would like to get a small server setup that doesn't draw a load of current keeping the costs down. I need to be able to do the following with it though.

1) log in on a remote terminal when out and about, be it phone, tablet, other PC via a web browser
2) transfer files to and from the connected usb hdd (so a file browser or something for its needed i guess, not sure)
3) have multiple login accounts (i will be sharing it with 3 friends as they also add to the collection)
4) if possible, and this is entirely IF its easily done, stream the video files (kinda like youtube)

but heres the thing, i've been trying to get apache setup in qemu (windows desktop) as i need to get another Pi and been having issues, so i was wondering if anyone has a good walkthrough or advice on how to proceed from the very beginning?

The other thing is, there are 2 mobile phones, 2 tablets, a desktop, laptop and 2 game consoles connected to the router by various means, most are wireless but the desktop and one console is on a ethernet connection, so obviously i dont want to be getting people logging into devices other than the Pi server.

I have no real need to do anything locally on the network other than SSH in to add new files to the servers shared files hdd. but then the server will have its own monitor and keyboard anyway so can still use usb to transfer files so ssh isnt really that important.

hopefully i've been clear in the end game goals.

all anime has been legally pruchased by myself and 3 friends, we just want a central location where we can store it and access when out and about instead of lugging around all the blurays and dvd's.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 4:06 pm

Good news, i picked up a RPi starter kit from maplin as it had everything needed really even mains powered usb hub and a dual usb power supply for the Pi which means i can run another 5v device from that, kool.

anyway, going to start playing, going to check cherokee first, but yeah, not sure what OS is on the preconfigured SD card so we'll see

just running

Code: Select all

sudo apt-get update && sudo apt-get upgrade
for the time being.

User avatar
RaTTuS
Posts: 10549
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: PI file sharing server with remote login

Tue Dec 17, 2013 4:10 pm

sudo adduser person
for serveral persons
sudo smbpass -a person
to add user to samba access
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 4:15 pm

wait, what? samba?

User avatar
RaTTuS
Posts: 10549
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: PI file sharing server with remote login

Tue Dec 17, 2013 4:27 pm

samba makes it easy to share files from a remote location if you don't want that
just having multiple user accounts and set them in a group then have the group have read access tot the collection
login remotely via ssh or whatever you fancy
you can copy via winscp , scp or similar no need for web access though you can do that via apache
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 4:30 pm

might have to look into samba then, but i did hear its quite hard to setup, also im looking to make the file transfer as easy as possible as the friends using it arent linux (or generally) tech savy

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 5:00 pm

im trying to use the following

Code: Select all

usermod -d /var/www pi
but getting this

Code: Select all

usermod: user pi is currently used by process 2561
any ideas?

also my hdmi outputs no longer working.....

Volatility
Posts: 2
Joined: Tue Dec 17, 2013 4:38 pm

Re: PI file sharing server with remote login

Tue Dec 17, 2013 5:10 pm

Have you considered using something like owncloud?

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 5:18 pm

never heard of it to be honest

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 5:50 pm

been looking at owncloud but you need a domain to do it, was hoping to just use the isp provided i.p address.

hence making sure people dont end up logging into the other devices on the home network from the isp ip address.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 6:39 pm

okay, so now im really confused.

can someone give me a starting point i can work from to get this going?

i mean, i can get apache installed and the browser page saying "its working" but no idea how to go about adding a visible FTP or login from another machine on another network.

new to all this, but really could do with some solid help

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 8:01 pm

WOOOOOOO

so i can access the "it works" page from any internet enabled device!

now i just need to make a html website that will allow the searching of files on an attatched hdd and download single or multiple files at a time.....any ideas where to start on that?

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 8:27 pm

even more progress, i love tinkering!

figured out if you remove the index file with the default apache page, you can just add files for download!

although i do need some help getting a login page to display before displaying files in the /var/www file directory and also changing that directory to a usb mounted external hdd please

User avatar
DougieLawson
Posts: 38451
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PI file sharing server with remote login

Tue Dec 17, 2013 8:38 pm

To get password protection you'll need to add these directives

Code: Select all

<Directory /var/www>
Options -Indexes
AuthUserFile /some/other/directory/webpasswd
AuthName "Password Required"
# NOTE: basic authentication has no security
AuthType Basic

require user usernamehere
</Directory>
And create /some/other/directory/webpasswd with

Code: Select all

htpasswd -c /some/other/directory/webpasswd usernamehere
NOTE: That password file MUST NOT be anywhere in /var/www or in any subdirectories under /var/www.

See: http://httpd.apache.org/docs/2.2/howto/auth.html for details. I'd also recommend using AuthType Digest to make it more secure (depending on your needs).
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 9:27 pm

that first batch of code, where is that going? is it here /etc/apache2/sites-enabled/000-default?

and the second file, i assume the root directory would be fine?

User avatar
DougieLawson
Posts: 38451
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PI file sharing server with remote login

Tue Dec 17, 2013 9:31 pm

secretreeve wrote:that first batch of code, where is that going? is it here /etc/apache2/sites-enabled/000-default?

and the second file, i assume the root directory would be fine?
I assume you have /var/www defined in 000-default. So yes add the directives to there.
I'd probably create a directory with mkdir -p /etc/apache2/var/www and put the password file in there.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 9:35 pm

awesome, thanks for that, any idea how to change the default directory?

I'm currently using a 32gb sd card in a reader till i can go out n buy the 4tb hdd needed as everything is stored over multiple drives and thats just gunna complicate things otherwise.

User avatar
DougieLawson
Posts: 38451
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PI file sharing server with remote login

Tue Dec 17, 2013 9:53 pm

If you attach a USB HDD it will appear as /dev/sdX (normally it's /dev/sda but it's not guaranteed) and depending on how many partitions are on the device they will appear as /dev/sdX1 /dev/sdX2 ... etc.

You mount those on a mount point (normally we'd use a subdirectory in /media)
mount -t <fstype> -o <mount-options-like-uid-gid-umask-dmask-fmask-etc> /dev/sdX1 /media/filesystem1 # doesn't have to be that directory
(There's lot of variables for the mount command depending what filesystem type is on the device.)
The man mount command has all of the ugly details.

Then when it's mounted you can use /media/filesystem1 (my example only) everywhere where you have /var/www now.

BUT, that device must be mounted before you start apache.

Try it with a USB memory stick to see what happens when you insert it. It works just the same way as a hard disk.
Look at the output from a dmesg command as soon as you've inserted it (dmesg will produce lots of meaningless noise but it should be clear at the end of that stuff).

There are ways you can ensure that a device always gets the same name.
https://www.google.com/search?q=label+u ... errypi.org will turn up lots of other posts on here with the same problem.

If you can reformat your USB hard disk with an ext4 filesystem it will be much easier, but if you want to unplug it and use it on Windows then it will have to be VFAT.

I hope that isn't too much strange jargon for you. I can't find a way to explain it without using the crazy jargon (which is second nature to me).
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 10:00 pm

i can manage to make a usb hdd in ntfs mount up when the Pi starts anyway, bout the only thing i can remember to do, so just change the /var/www in the various files and all should be good then,

thanks!

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 11:26 pm

does this look right?

Code: Select all

<VirtualHost *:80>
        ServerAdmin [email protected]

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride ALL
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride ALL
                Order allow,deny
                allow from all
        </Directory>

        <Directory /var/www>
               Options -Indexes
               AuthUserFile /etc/apache2/var/www
               AuthName "Password Required"
# NOTE: basic authentication has no security
               AuthType Basic

               require user mainframe
               </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride ALL
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
because im not getting a password request from the server

now i rebooted the system, im getting The connection was reset in the broswer

User avatar
DougieLawson
Posts: 38451
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PI file sharing server with remote login

Tue Dec 17, 2013 11:32 pm

Code: Select all

    <VirtualHost *:80>
            ServerAdmin [email protected]

            DocumentRoot /var/www
            <Directory />
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride ALL
                    Order allow,deny
                    allow from all
                   AuthUserFile /etc/apache2/var/www
                   AuthName "Password Required"
                   AuthType Basic
                   require user mainframe
                   </Directory>

            ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
            <Directory "/usr/lib/cgi-bin">
                    AllowOverride ALL
                    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                    Order allow,deny
                    Allow from all
            </Directory>

            ErrorLog ${APACHE_LOG_DIR}/error.log

            # Possible values include: debug, info, notice, warn, error, crit,
            # alert, emerg.
            LogLevel warn
I've stripped a few lines out.
You'll need to create the /etc/apache2/var/www password file
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 11:40 pm

i already created the password file so wondering do i need to re-create it or just use the same username for it?

User avatar
DougieLawson
Posts: 38451
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PI file sharing server with remote login

Tue Dec 17, 2013 11:43 pm

secretreeve wrote:i already created the password file so wondering do i need to re-create it or just use the same username for it?
It should work. The password file isn't very complex. Have a look at it with cat /etc/apache/var/www.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: PI file sharing server with remote login

Tue Dec 17, 2013 11:47 pm

yeah i went in and had a look at it a little while ago.

okay, i went in with

Code: Select all

 sudo nano /etc/apache2/sites-enabled/000-default
deleted everything

put your code in

and still getting a connection reset problem. thats with a reboot, redoing the password file and another reboot

i really appreciate all your help on this project

User avatar
DougieLawson
Posts: 38451
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PI file sharing server with remote login

Tue Dec 17, 2013 11:49 pm

What's in /var/log/apache2/access.log and /var/log/apache2/error.log?
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Networking and servers”