+-----------------------------------------+
| Server: Part 1                          |
+-----------------------------------------+-------+
|                                                 |  
| Date: 20181124-13:15                            |  
| Author: Sloum                                   |   
| Soundtrack: Black Metalic by Catherine Wheel    | 
|                                                 |   
+-------------------------------------------------+-------------------------+

As mentioned earlier, I am trying to set up a small ssh/gopher/code portal.
I have decided to document the setup process here. I am setting this up with
a Raspberry Pi Zero W. Here is what has been done so far:


Step 1: Get the Pi up and running
----------------------------------
This step is pretty basic. Inserted the SD card into a computer/laptop and 
use Etcher[0] to flash Rasbian Lite onto the SD card. Then unmounted the card
and put it into the Pi. After that plug the Pi into a monitor and keyboard (I
used a terrible cheap keybaord my wife had meant to throw away). Boot up and
log into the Pi. Default user is "pi" and default password is "raspberry". 

At this point I recommend changing the password for the "pi" user. I did this 
via the "passwd" command, but it can also be done with "raspi-config", which 
will be used for other things in the next step anyway.


Step 2: Configure WIFI & SSH
----------------------------------
In "raspi-config" changed the hostname to what you want it to be. Then update
the time zone and locale. I am running wireless (via WIFI) rather than using
ethernet. Getting the WIFI on the Pi to work was a really big pain. It tookctr
quite a lot of time to get going. First you will want to set the WIFI country
in the "raspi-config" tool. While in the tool activate SSH.

While it is possible that your Pi may just work on WIFI at this point, it
seems unlikely. Here are some things to try:

- Running "sudo iwlist wlan0 scan" will show you available WIFI networks.
- Edit "/etc/wpa_supplicant/wpa_supplicant.conf" as administrator as follows:

	ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
	update_config=1

	# Use your country code
	country=US

	network={
		# use quotes around the ssid & psk
		# replace networkname with your access point name
		# replace networkpassword with your access key
		# key_mgmt gets set as what you use e.g. NONE or WPA-PSK
		ssid="networkname"
		psk="networkpassword"
		key_mgmt=WPA-PSK
	}

- Edit "/etc/network/interfaces" as administrator to be similar to:

	source-directory /etc/network/interfaces.d

	auto lo
	iface lo inet loopback

	allow-hotplug wlan0
	iface wlan0 inet static
		#your local IP here
        	address x.x.x.x 
		#your netmask here
	        netmask x.x.x.x 
		# your gateway here
        	gateway x.x.x.x 
	    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

- Run "sudo systemctl disable dhpcd && sudo systemctl enable networking"

- Backup sshd_config file: 
	"sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults"

- Edit sshd config as desired (lots of settings options available)
	I sandbox all users except root to force chrooted SFTP access

- Update the "/etc/skel" directory so that new users get set up the same way

- Log into ssh locally: "ssh username@host.local"
	This will use passwords unless you already set up using
	authorized keys during the sshd_config editing phase.
	
	I set mine up to use authorized keys and organized a file
	structure for storing those keys based on username as part
	of my sshd_config.

-------------------------------------------------------------------

That is basically where I am at. I, of course, also updated and upgraded
via apt. Installed vim, updated vimrc, updated bash_aliases, etc.

I am looking into gopher server software options. It seems like gophernicus
is likely the best call, but it would be fun to support a less mature
project if I can find something that will work well.

I am going to start coding a custom shell in Python soon and will likely
document that process in the coming updates.

I am still thinking about doing version control hosting as well. I am 
trying to decide between Bazaar[1] and Git. Bazaar has some cool stuff 
going for it... meh. I'll keep thinking on it while I get gopher set up 
on the pi.

Lastly, I need to get dynamic DNS set up. I got a static IP assigned by
my router and port forwarding set up for SSH and Gopher. Do any of you
have advice for dynamic DNS providers, gopher server software/daemon,
custom shell styles, etc? Feel free to respond via your gopher or email
me: sloum@sdf.org

I hope those of you that celebrate it had a lovely thanksgiving! I had 
a great time with family and have been enjoying the long weekend. 



[0] https://www.balena.io/etcher/
[1] https://bazaar.canonical.com/en/