Add FTP functionality to new or existing piratebox

Posted by IDE286 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
Add FTP functionality to new or existing piratebox
March 28, 2019 04:18AM
### If you want to add ftp function to existing piratebox. Make sure you backup your sd card before continuing.

### My advise is to avoid Sandisk cards at all cost because they are problematic. Basically you get what you pay for.
### Download and dd the original piratebox image to sd card on computer (Skip this step if you already have piratebox running)
# Beep is optional but nice to have to alert you when your card is ready
sudo apt-get install beep -y

# Identify your destination disk (be very careful not to write to your internal drive by mistake)
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

# dd the image to the card. replace the X in sdX with your destination dev identified in the previous command.
sudo dd if=/dev/zero of=/dev/sdX; n=500; while [ $n -gt 0 ]; do beep -f $((RANDOM % 3500 + 100)) -l 30;n=$[$n-1]; done;

### At this point, safely remove the card from your computer. Put it in the raspberry pi and power it up with an ethernet cable connected to the same network as your computer. Identify the ip address in the router or connect a monitor and keyboard to your raspberry pi before powering up

# From computer terminal (You can skip ssh if you have a keyboard and monitor connected to the pi itself)
ssh alarm@[RASPBERRY_IP_ADDRESS]
# default password is alarm

# Either through ssh or directly interfaced with the raspberry pi

#repairs pacman command
sudo rm /etc/resolv.conf
sudo sh -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf '

#installs ftp server
sudo pacman -S vsftpd

#Complete Piratebox initial setup if not done so already. Otherwise skip this step. In my case I followed these steps and used the SDCard command with a 32GB microSD.
First Steps After Flashing
1. Change password of alarm user
> passwd
2. Change password of root user
> sudo passwd root
3. Enable Fake-Timeservice
3.1 Set date and time
# Disable network time sync
> sudo timedatectl set-ntp false
# Set time to "Mon May 23 17:42:00" (Format: CCYYMMDD hhmm)
> sudo date -s "20170523 1742"
> cd /opt/piratebox && sudo ./bin/timesave.sh ./conf/piratebox.conf install
3.2 Enable on startup
> sudo systemctl enable timesave
4. Enable the Kareha Image and Discussion Board
> sudo /opt/piratebox/bin/board-autoconf.sh
5. Enable USB thumb drive share OR extend SDCard
USB: > sudo /opt/piratebox/rpi/bin/usb_share.sh
SDCard: > sudo /opt/piratebox/rpi/bin/sdcard_share.sh
6. Enable UPnP Media Server
> sudo cp /etc/minidlna.conf /etc/minidlna.conf.bkp
> sudo cp /opt/piratebox/src/linux.example.minidlna.conf /etc/minidlna.conf
> sudo systemctl start minidlna
> sudo systemctl enable minidlna
7. Enable RealTimeClock timekeeping (needs DS3231 or 1307 RTC module!)
> sudo systemctl enable rpi_hwclock


### after piratebox is working
-----
nano /etc/ssh/sshd_config

#uncomment the following line if necessary
Subsystem sftp /usr/lib/ssh/sftp-server

#run this command only if you had to uncomment the above line
sudo systemctl restart sshd
-----


sudo nano /etc/vsftpd.conf

#add, uncomment, and/or edit the below lines and save
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=000
nopriv_user=alarm

# run after saved
sudo systemctl restart vsftpd

# give RWX to mnt folder (Should work for both SDcard and USB case. My case was SDcard)
sudo chown -R alarm /mnt
sudo chmod -R 777 /mnt

### At this point you should be able to use your ftp client to login either through the ethernet or wireless connection.

Wireless connect is:
[192.168.77.1]
Username: alarm
Password: alarm (unless changed)

Navigate to /mnt/sdshare/Shared

This directory is the location of all the files uploaded through piratebox website. You should also be able to upload multiple files here and they will automatically update on the piratebox internal site. You can also delete files here if necessary. Be careful not to delete any system files. If you are using a USB drive, It might me usbshare instead of sdshare but I never tested this with USB.

Hope this helps anyone who needs a portable FTP server in addition to a piratebox.

Feel free to make suggestions to improve on this
Re: Add FTP functionality to new or existing piratebox
May 09, 2019 02:35PM
Thanks for this. I'll give it a try.