Category Archives: DIY

Project: Raspberry Pi Kiosk Display

If you’ve got a Raspberry Pi lying around and you were wondering about what you might do with it, consider using it to drive a presentation kiosk.

This post doesn’t describe how to set up a Raspberry Pi from scratch. Getting a new Raspberry Pi up and running requires a collection of materials and a bit of time, which is the price one pays for being able to buy a $35 computer. There are a wide variety of tutorials on the web describing how to make that happen, including this YouTube presentation by yours truly.

Assuming you’ve already got your Pi running, though, here’s how you can set up a presentation kiosk that will cycle through a slideshow.

1. Create and test your presentation using LibreOffice Impress software. You can do this on a separate machine running LibreOffice or on the Raspberry Pi itself. You’ll want to set up the slide transitions and the presentation repeat. (Also, if you’re using images in your presentation, be careful of using high-resolution images. I’ve had presentations choke to a halt when given too many high-res images to present.)

2. Using the terminal, download and install xscreensaver.
$ sudo apt install xscreensaver
This is the only way most people have found to reliably keep the screen from sleeping while you’re using your Raspberry Pi in a kiosk mode. Once the software is installed, you can disable the screensaver in the Accessories settings.

3. The system is now effectively running as a kiosk, although you have the Raspberry Pi, the mouse, the keyboard, and a tangle of wires all over the place. To clean things up a little, get some 3M Dual Lock reclosable fastener tape and put one strip on the Pi housing and one on the back of the monitor. You can attach the Pi to the back of the monitor now, and get it up and out of the way.

4. Once you’ve got the display set up and running in a desired location, go ahead and unplug the keyboard and the mouse from the Pi. That way it will be harder for the presentation to be accidentally interrupted.

What can you use this project for?

  1. Showcasing student work
  2. A vehicle for student investigation of the Raspberry Pi or Open Source software
  3. Presenting program information to visitors at Open House or Back-to-School night

Materials

Open Sourcing

Fun story.

For my own use and as a programming activity, I wrote a little Python script that I could use as a countdown timer. (Bonus feature: I can run multiple timers at the same time. Apple iOS, I’m looking at you!)

I wanted to have a little bell that would ring at the end, and look at that, GarageBand has a little alarm bell sound! Here it is:

I was going to throw my little project up on GitHub as an example for my students; also, because I’m A Developer. I was pretty sure I wouldn’t have a problem packaging Apple’s alarm bell sound with that project. I mean, I’d already had to go to the mat with Google/YouTube about a song I’d made using some of Apple’s sound loops, and I’d done my research. At just under 30-thousand words (at that’s only for the English version) you can polish off GarageBand’s User License Agreement in an easy afternoon, and here’s the good news about GarageBand projects:

H. GarageBand Features and Support.
Except as otherwise provided, you may use the Apple and third party audio loop content (“Audio Content”), contained in or otherwise included with the Apple Software, on a royalty-free basis, to create your own original soundtracks for your video and audio projects. You may broadcast and/or distribute your own soundtracks that were created using the Audio Content…

Cool! Oh… but wait….

…however, individual samples, sound sets or audio loops may not be commercially or otherwise distributed on a standalone basis, nor may they be repackaged in whole or in part as audio samples, sound libraries, sound effects or music beds.

Dammit, Jim. I can’t use that file in my project. Oh, and maybe I just violated the license by embedding that file here.

What should I do for my project? Quick fix: borrow a desk bell from the Theater Department at school, record a single “ding!” and process it using open source Audacity (“Screw you, GarageBand.”), et voila:

My project–including that alarm bell!–has been posted on GitHub: https://github.com/rwhite5279/timer . Mischief managed.

For the record, I totally get why the GarageBand license agreement would restrict redistribution of files. It’s just another in a long list of Apple-related frustrations for me and I needed to vent a little.

Plus, I wanted to play you my bell recording. I’m quite proud of it! ;)

Demo: Binary Numbers

If you teach Computer Science, chances are that learning about the binary numbering system is part of the curriculum at some point.

Why teach binary?

Some people question whether or not binary numbers should be part of a high-level curriculum, given the multiple layers of abstraction between, say, a webpage and the binary code that brings that page to life. I’d suggest that:

  1. Those multiple layers of abstraction / encapsulation are very much a part of computer science, and a perfect jumping off point for a conversation about binary numbers.
  2. Students should understand that binary numbers are at the heart of every computer. A great video for demonstrating how people used to have to program computers is this one, demonstrating the programming of an old 8080 microcomputer. Follow that up with a demo of high-level / assembly / binary version of a program, described here.
  3. Learning how to decipher a binary number is not that difficult, and provides students with a manageable gateway activity to the field of computer science.

Demonstration strategies

Binary numbers can certainly be displayed on a computer monitor or projected in front of the class. An interactive Python session works just fine:

>>> bin(13)
'0b1101'
>>> print(bin(13))
0b1101

A more visible and physical demonstration of binary numbers can easily be constructed using an outlet power strip, socket adapters, and low-wattage aquarium light bulbs (see parts list below).

This device can be easily manipulated at the front of the room, with individual bulbs easily turned on or off simply by screwing them in tightly (on), or unscrewing them slightly (off). Students can be asked to identify the decimal equivalent of a binary number, or asked to manipulate the bulbs themselves to produce the binary equivalent of a decimal number.

Conclusion

This inexpensive and physical, practical demonstration device can be used in the classroom, with parents, during open house events, etc. It has become a mainstay of every CS course I teach.

Parts List

MOOCs and You

MOOCs and You
Richard White
2013-03-23

Doug Johnson, as always, has words of wisdom over at Blue Skunk Blog, where he regularly weighs in with wisdom and insight on the very same topics that I find so interesting: the intersection of technology, teaching, and learning.

His January 29 entry is entitled “MOOCs—need K-12 pay attention?”, and if it has taken me two months to weigh in on the topic for myself, well… it’s an important question that’s worthy of some reflection.

Massive Open Online Courses (MOOCs) have been discussed here before. Massive Open Online Courses are the Internet-enabled version of what we used to call a distance-learning course, although the new and improved version often includes enhancements like asynchronous discussion boards and wikis, video presentations from world-class instructors, perhaps some interactive online experience, and (if they’re doing it right), some form of periodic assessment, as well as a final assessment. If you get through the course you at least get a PDF certificate and a congratulatory email, and if you’ve paid some money, you may get some course credit that can presumably be applied toward a degree or certification program somewhere. Or, maybe you’ve dropped out of the course somewhere along the way, in which case you’ll be in very, very good company. Some ridiculous percentage of people who enroll in this courses don’t end up completing them.

(I myself have a 33% completion rate based on the three courses I’ve enrolled in, only one of which I managed to find time to complete… and even that was touch and go for a bit.)

The development of MOOCs such as Udacity, Coursera, and MIT’s Open Courseware (now looking a little dated) are an important development in the evolution of education, any way you look at it. Getting back to the Blue Skunk blog, the question Johnson raises is, “As K-12 teachers, what does it mean to us?”

I won’t repeat his thinking on the topic—head on over to his post to check it out—but my own thoughts on the matter parallel his in some ways. Certainly there are some students in the 9-12 grade range who might be in a position to benefit from online learning. For many students in this age range, though, and certainly for students at a younger level, a good deal of learning is bound together with the relationship that one develops with a teacher.

Most of us have favorite teachers that we remember from our youth, or even from college, and we found ourselves influenced by them in important ways, as a parent, youth group leader, or religious leader might influence us. As adults now, and as teachers, aren’t the parents of our students, of course, but we are very much, emotionally and legally, in loco parentis for our students during the school day, so the fact that we develop important relationships with our students isn’t a surprise.

As long as we have this kind of responsibility for our students, and as long as these kinds of relationships are important for encouraging our students, I don’t think any of us are in any real danger of losing our jobs to a Javascript running on a Khan Academy server somewhere. The interactions that we have with our students as we help them to learn and to grow are a vital part of their development, and our communities and institutions rely on us to encourage students along that path. The students rely on us as well.

There are rare exceptions, of course—self-learners who teach themselves from a book, or who academically bootstrap themselves—and more power to them. The MOOCs may become an important tool for them.

Learning can scale very nicely on the Internet. Given a MOOC, and Wikipedia, a little curiousity and the right starting conditions, the self-starting learner can accomplish wonders. But teaching does NOT scale. Teaching—where I sit down with a student, learn a little about who he or she is, give them a little academic shove in the right direction, and help them figure out the answers to their questions along the way—that’s a one-to-one process. Even in a classroom of 10 kids, or 15 kids, or 23 kids, or—God help you—40+ kids—teaching is about developing a relationship with your kids so that you can help them move in the right direction.

That’s one thing that the Internet can’t do, and will never be able to do.

For the educator who loves working with kids, that’s the good news. The bad news is that you’re still going to have to sit down with your students’ homework and take a look at how they’re progressing, a process which (for me and most of the teachers I know) quickly becomes tedious. Even scantron assessments, ideally, require interpretation and discussion.

And even computer programs written by my students require sitting down, late at night, with tired eyes, and making a few comments on their individual work.

It’s what we do. We’re teachers.

It’s a Jungle Out Here

IT’S A JUNGLE OUT HERE
Richard White
2013-03-14

I’ve been wanting to write for a long time about the challenges that technology users face in some schools, in some rooms, in some educational cultures. It’s something that we all face on occasion, from a colleague who “doesn’t really do technology” to a school leader with an uninformed knee-jerk reaction to social networking, from infrastructure that is unable to support the increased hardware and bandwidth demands of a classroom to pure, simple, reluctance to change… being on the leading edge of technology-based education reform—and worse, being on the bleeding edge—is not for the meek.

You can insert your favorite Don Quixote quote here if you like.

A little bit of a wildcat mentality may come in handy if you’re more gung-ho than your colleagues, administration, or school is currently willing to support… and dare I say it, a little bit of cash. When LCD projectors first dropped to the barely-sub-$1000 price range a few years ago, both I and a colleague of mine each bought one. It’s not that we had loads of cash lying around; it’s just that we were *that* committed to trying to transform the way we were doing things in the classroom.

If your school can’t buy you a computer that meets your needs, try to beg, borrow, or buy one that will.

If a decent backup strategy for your computer isn’t currently available to you, buy a service, or get an external hard drive, or learn how to roll your own backup strategy on a friend’s server.

If your kids don’t have “clicker”-style Classroom Response Systems, get a set of whiteboards and dry erase markers that they can use to record their responses for display to the instructor.

If your school blocks YouTube, use a video downloader plug-in like Flash Video Downloader to pull down the video locally onto your computer and show them from there.

The point is obviously that there are almost always options. We just need to be creative.

Will Richardson tells the story in one of his blog postings about the time he was giving a presentation at a school, and there was one teacher who kept road-blocking efforts to move forward technologically. “Yes, but that won’t work because…,” and then, “I tried to do that, but…” Finally tired of the negativity, Will stumbled upon a response that both acknowledged the man’s concerns and placed the responsibility for addressing those concerns squarely on his shoulders: “Yup, you’ve got some challenges there. So what are you going to do about that?”

“What are you going to do about that?”

It’s a jungle out here, and we’re all looking for ways to survive. It’s okay. We signed up for this. We can deal with it.

I stumbled upon this post a couple of days ago, which is a nice reminder of how we sometimes need to do things a little differently. It comes from the Business section of Wired Online, but I think it’s got a lot of relevance for educators as well.

Check it out: http://www.wired.com/business/2012/06/resiliency-risk-and-a-good-compass-how-to-survive-the-coming-chaos/

Five Things To Do at the End of the School Year

FIVE THINGS TO DO AT THE END OF THE SCHOOL YEAR

2012-06-15

by Richard White

It’s the end of the school year, and maybe you’ve had a chance to close things out in your classroom. How about taking a few moments to close things out on your computer, too?

Here are six things to do with your computer at the end of the school year.

1. Backup Everything
This should go without saying, but I’m always amazed at how many people don’t have a backup of their computer. If you don’t already have at least two local backups of your Documents folder, and if you don’t already have a subscription to an offsite backup solution like Backblaze or Carbonite, you’ll be pleased to know that you are excused from the rest of this assignment. YOUR assignment is to:
a. order one of these or something similar with 2-day shipping from Amazon, and then set up your computer to do automatic backups (Time Machine on the Mac, Backup and Restore on Windows 7).
b. While you’re waiting for your hard drive to arrive, you can go to Backblaze or Carbonite, give them $50-$60 on your credit card, and sign up for a year’s worth of offsite, in-the-cloud, backups. Because… your computer is going to crash. If it’s happened to you already, you know what I’m saying, and if it hasn’t happened to you yet, don’t worry: it will…!

2. Archive Last Year’s Material
With any luck at all, you’ve already got someplace in your Documents folder where you’ve saved all the work you’ve done this year: those tests you wrote, those handouts and worksheets you created, etc. Those should all be dragged into a folder called “AcademicYear2011-2012” or something similar. And if those documents are scattered willy-nilly about your desktop, that’s all the more reason to take advantage of this opportunity to assemble them all in one place.

(The reason for this is two-fold. You want to reduce the amount of time and energy you waste digging through old documents that aren’t actively being used, and you want to reduce the amount of time and energy you spend looking for those documents when you do need to find them.)

You get extra credit for organizing the files from this academic school year into sub-directories labelled by class.

3. Archive your email
If you’re like many teachers I know, you have a drastic drop-off in the amount of work-related email you get during the summer. Now’s the perfect time to tidy up that Inbox. Archiving or exporting email, depending on which email process you use and what facilities there are for archiving, may make your Inbox faster loading and easier to navigate.

There are numerous strategies for doing this. Google’s web-based Gmail and Apple’s Mail.app both offer convenient commands for doing this right from the interface (see screen captures below). Consult the documentation for those services, or check in with your local IT staff for specific advice on how to export or archive your own email.

4. Digitize Your Stuff
If you’re still carrying around paper copies of your class materials, the end of the school year is a perfect time to digitize. Anything that’s a Word document or a PDF is easily stored in the appropriate folder on your computer. Anything that’s NOT, and that you need to keep for future reference, can be scanned as a PDF and tucked away into a folder on your computer, where it will be (in most cases) far easier to find, and take up far less space (like, *none*) in your filing cabinet.

5. Get Organized
Everybody loves a little Spring Cleaning, and the chance to clear out the detritus that naturally accumulates over time. (You have heard of the Second Law of Thermodynamics, haven’t you?)

There’s a note I keep on my computer to remind myself of the benefits of keeping organized. It’s from a talk on What We Know About Learning given by a professor at Caltech last year, and it simply says, “Simple frameworks reduce cognitive load.” The idea is that creating a framework or structure that you can use to organize your understanding makes it easier to learn, and I’m obviously extending that idea to the hard drive on your computer. Get things organized on your hard drive, and it will be easier for you to access and work with that information.

Here’s the directory structure of a folder on my hard drive called “edu,” into which I’ve placed a number of different folders for various educational contexts. The “poly11-12” folder contains sub-folders of the files I’ve used this year in my courses and other contexts at school. I leave those files and folders there as a record of what I did that year. If I need a copy of a file for the new school year, I do just that: I make a copy for the new year, and leave the original in place.

The End is Nigh

The End is Nigh

2011-12-01

by Richard White

“The End is Nigh!” For your optical drive, that is.

CDs and DVDs are still here for the moment, but not for long. Depending on how much you love your archives and content, it may be time to start thinking about a migration process that will allow you to convert your CDs and DVDs to a hard drive.

It’s an easy, if tedious, process. I did it with my documents and data last year: buy a couple of 1-terabyte external hard drives, plug one of them into your computer, plug in the nearly endless succession of CDs and DVDs that you’ve been burning data on all these years, and click-drag over to the terabyte archive.

Once you’ve spent a day or two doing that, plug in both terabyte drives and click-drag all the contents from one drive to the other, which will act as a backup of the archive.

At that point you’ll have at least three copies of your data: the original CD or DVD (which you might want to tuck away, should something catastrophic happen to both hard drives), and two copies of your data on the Archive and Backup external drives.

There are fancier ways to do this that you may already have built. rsync works magic in a shell script, and you can spend hours and days developing a system there that you can use to manage it all.

In the absence of anything fancy, though, at least get your data off those optical drives. In another three years or so, many computers—and certainly the most popular ones, including iPads and Macbook Airs—won’t have an optical drive, and you’ll have easy way to access that data. Let’s face it, the data storage on CDs and DVDs is time-sensitive anyway. Like that old slide film that your father shot just thirty years ago, that medium decays with age. If you think that Apple is wrong about that, you don’t have to look too far back to find another decision they made regarding media that was very controversial at the time. The 1998 iMac G3 came without a floppy disk slot in anticipation of what would happen throughout the industry in the years to come. By 2003, Dell was no longer including floppy disk drives as standard on their machines, and by 2007, only 2% of computers sold included floppy drives.

So, yeah. I’m not saying you need to run out right now and take care of this. But you might want to put it on your ToDo.txt list. I mean, come on. When’s the last time you bought a music CD?

Yup. That’s what I thought.

Do yourself a favor and get a couple of 1-terabyte archive drives. You’ll be glad you did.

Housekeeping

HOUSEKEEPING

by Richard White

2011-07-29

It’s Housekeeping Day on the website.

Like a lot of teachers, I have a website associated with each one of my classes, and over the course of a year, that website can get a little messy. Here’s the calendar that I used in the Fall, and there’s the results of that mid-year teacher/text/course evaluation that I posted (I’m a big believer in transparency). Here’s a picture of the class from the beginning of the year, and there’s a video of all of my students trying to squeeze into one cubic meter of volume (they didn’t make it, but it sure was fun trying).

I’ve got to clean all that stuff out and get things ready for the new school year.

There’s something else that I often do at this time of year, depending as always on time constraints. I was listening to website designer Paul Boag talk at one point about managing sites, and he said something that I thought was quite profound: “Many websites have someone responsible for adding new content to the site… but who’s responsible for taking away old content?”

Not all old content should be removed, of course, particularly if one of the site’s functions is to act as a repository of accumulated knowledge. But this isn’t necessary for the vast majority of sites, and certainly not for my class websites. This year’s students don’t want to be greeted with a photo of last year’s class when they log on, and the materials that I used last year may be markedly different from what I use this year.

So it’s time to do a little cleaning, and a little pruning. (Below, see the homepage screencaps for three websites that I maintain for different groups of students I work with.)

It may even be the case that you want to look again at the design of your site. Ten years ago I was very pleased with what I felt was the optimal design of my site, until I spent an hour waiting in line at the movies with my friend Aaron doing usability studies with a pile of index cards that I’d prepared specially for the occasion. By the time we were admitted into the theater, I had a completely new perspective on how my site was viewed by someone woho wasn’t me, and the result was an enormous improvement in usability, as indicated by my students in subsequent interviews.

Switching between horizontal and vertical orientations on navigation menus can make a website feel completely different. Moving “Terms of Service” from a prominent location at the top to the barely noticeable footer at the bottom of the page is almost certainly a good idea. Switch from a fixed-width content area to a liquid layout (that resizes with the browser window)? Change themes? Colors? Rollovers? Remove graphics to make the page load faster? Add graphics to increase visual interest? Add a version of your website customized for an iPhone/Android experience, or at least make your website look okay on a mobile screen?

The possibilities for tweaking are endless, which is what makes designing for the web so fun, and so challenging.

I’m not sure I’m going to redesign my website today—that process typically takes a few days, and lots of chatting with people to find out what they like and don’t like. Today, I think I’ll just clean out the old content. That’ll take an hour or two all by itself.

August is almost here—is it time to start thinking about school yet?! ;)

Thank God for Mac OS X

Thank God for Mac OS X

by Richard White

2011-07-24

There’s a line that rock climbers sometimes trot out when they feel like exulting in the glory of their source of creativity.

“Thank God for the rock. Otherwise, we’d all be surfers.”

In the same way, it has occurred to me on more than one occasion to say to myself “Thank God for Mac OS X. Otherwise, I’d be using Linux.”

Now the reality of the situation is that Mac OS X and Linux share a common ancestor: UNIX. Actually, the Mac OS X running on all current Apple computers really is UNIX at its core. I’m thankful to the Mac platform in part for giving me a jumping off point from which to learn about UNIX, and later on, Linux. In 2004, O’Reilly published Learning Unix for Mac OS X Panther, by Dave Taylor & Brian Jepson, which turned out to be a great to begin discovering some of the inner workings of the OS X operating system.

One of the best things about OS X, then, is the fact that one can peek under the hood and play around with things a bit. This has always been the case with computers, of course, but OS X’s use of UNIX means that there’s a fairly large base of users with UNIX experience that can assist one in playing with the system, or even running other software on the system—UNIX-based software—that actually isn’t part of the official OS install.

This past week, Apple released the long-awaited 10.7 version of the OS X operating system, named “Lion.” Apple has continued to improve on OS X over the years, and this release included some major developments that many users are going to find very appealing, including autosave, built-in version control, and updates to many Apple apps.

Some users, however, found some of the improvements to be less-than-satisfactory. In an otherwise clean and minimalist User Interface, for example, Apple’s iCal application sports a faux-leather and torn paper skin that is almost universally abhorred by users, for a lot of different reasons: the leather is inconsistent with the overall OS theme, the real life stitching and leather texture don’t contribute to one’s understanding or use of the application, the fake torn bits of paper on the upper margin are silly…

Fortunately, the power of the community stepped forth, and someone came up with a package that allows one to equip that calendar with a skin more appropriate to the UI, and made it available online: http://macnix.blogspot.com/2011/07/change-mac-os-x-107-lion-ical-skin-to.html. Thanks to the carefully written instructions there, my iCal calendar is back to looking like it should.

Apple’s Mail.app program received some interface changes as well, and that got me thinking about investigating some other ways of working with my email. Of course many people have already gone over to using a Web-based email system—Google’s Gmail is the most popular—but I still like the idea of being able to read and compose emails when I’m not actually connected to the Internet; I like having an email “client” on my local machine.

If you’ve used Apple’s Mail, or Microsoft’s Outlook or Outlook Express, or any one of a dozen other programs that run on your local computer, you might be interested to hear about another alternative, one that may appeal especially to the geeks among you.

Next time, we’ll see how to install a modern version of the Terminal program pine on your UNIX-based OS X machine.

How-To: Password Protecting a Website Directory with .htaccess

How-To: Password Protecting a Website Directory with .htaccess

by Richard White

2011-07-19

A friend of mine who maintains a website for his classes recently asked me how to go about creating a password-protected folder for the site. He wants to store materials on there that would be accessible to his students who would use a Name and Password to browse the folder.

In other words, when a user tries to go to a certain location on this teacher’s website, he wants them to have to authenticate with a Name and Password before they’ll be allowed to enter the site.

Here’s how you password protect a folder, in three easy steps.

1. Create the folder that will store the protected material.

For our example, we’ll assume that my account on the webserver is called rwhite, and the website files are all stored in public_html. In that directory public_html, create a new directory “secretstuff”, which is where we’ll be storing our password-protected materials. This folder should have a permission of 755.

(There are lots of different ways to “create a folder”, depending on how you manipulate files on your server. You might ssh in to the server, you might use Dreamweaver or Coda, … If you’re not sure how to manipulate files and directories on your server, learn how to do that first and then come back here!)

So in terms of your websites directory structure, here’s what we have so far (your files and directories will look different from mine–the ones shown are for example only):

/
|---home/
    |---rwhite/
	|---logs/
        |---mail/
        |---public_ftp/
        |---public_html/
	    |---about.html
            |---index.html
            |---secretstuff/

2. Use a text editor to create a text file called “.htaccess” in the folder that you want to protect.

To keep unauthorized users from peeking inside the directory secretstuff, you’ll need to add two additional files to your website that will instruct the server under what conditions it should display the contents.

The first file is a text file called .htaccess that is stored in the secretstuff directory. Note that this filename doesn’t really have a name—it only has an extension (the eight letters after the period). That means that this file won’t show up in most directory listings unless you specifically tell your computer to list ALL files.

Use a text editor—Notepad, TextWrangler, BBEdit, TextMate, vi, emacs, nano, edit, whatever—to create the .htaccess file in the secretstuff directory. The file .htaccess should include these four lines:

AuthName "Secret Stuff"
AuthType Basic
AuthUserFile "/home/rwhite/.htpasswds/public_html/secretstuff/passwd"
Require valid-user

Be sure to save the file with the name .htaccess (including the period in front!). That file should have permissions 644.

What does all of that mean?

First of all, .htaccess is used by the Apache web server to do all sorts of things on your website, and you probably already have a few .htaccess files sprinkled here and there on your site—we don’t want to mess with those. This particular .htaccess file in the secretstuff directory is simply being used to control access to that directory.
The four lines in that file, in order, say:

  1. Display this name in the authentication dialog box.
  2. Use Basic http authentication.
  3. Find the file containing passwords at this location on the server (see step 3 below).
  4. Make sure user has been authenticated before giving them access to this folder.

The only really tricky part about this step is the location of the password file. Note that the .htpasswds directory listed here is NOT contained in /home/rwhite/public_html—placing that directory in a publicly-accessible folder is a security risk. Instead, the .htpasswds directory is contained in /home/rwhite, which is not accessible by a browser. That location IS accessible to Apache, however, which will look at that location to find out which users will provide what passwords in order to gain access to the protected folder.

So here’s what we’ve got now:

/
|---home/
    |---rwhite/
	|---logs/
        |---mail/
        |---public_ftp/
        |---public_html/
	    |---about.html
            |---index.html
            |---secretstuff/
		|---.htaccess

3. Use a text editor to create the text file called “passwd” that we’ll place in the .htpasswds directory.

As discussed above, the passwd file will be be located someplace where a browser can’t get to it. Here’s where we’re going to put it.

/
|---home/
    |---rwhite/
	|---.htpasswds
	    |---public_html
              	|----secretstuff
		    |---passwd
        |---logs/
        |---mail/
        |---publc_ftp/
	|---public_html/
            |---about.html
            |---index.html
	    |---secretstuff/
		|---.htaccess

Note that if you don’t already have a directory called .htpasswds, you’ll need to create it, and then nest inside it the public_html and secretstuff directories. (Although some tutorials will instruct you to place a single .htpasswd file in those location, creating a directory will give you more flexibility later on, should you choose to create additional .htaccess authentications.) The .htpasswds directory and those nested inside it should all have permissions of 644, as should the passwd file itself.

Now, what actually goes IN the passwd file? For our purposes, it’s going to consist of a single line: the Name, a colon, and then the Password that a user will need to get into the password-protected secretstuff directory.

Assuming we want to allow ImaStudent to access the directory using a password of 123456 (not a very good password, obviously), that one line in the file passwd will contain both of those pieces of information, and look like this:

ImaStudent:EdQXJLHVRhCFo

Whoa, whoa, whoa. Where did EdQXJLHVRhCFo come from? That doesn’t look like our password 123456 at all.

That’s because EdQXJLHVRhCFo is an htpasswd “hash” of 123456. Apache is so security-conscious that it doesn’t even want to know what your real password is—it only wants to store a “hash”, or one-way coded version, of that password. When a user enters their password into the authentication box, that hashed password (the EdQXJLHVRhCFo, converted from 123456) will be compared to the hashed version in your passwd file.

So how do you know what hash to include in your passwd file?

There are a few ways to do this. One way is to go to a website like this one and enter your password into the indicated field.

Or, if you wish to do it yourself on the computer, open up a Terminal and on the command line, type

$ htpasswd -ndb ImaStudent 123456

…and you’ll get a line that you can paste into your passwds file.

Once you’ve got everything put together, try going to the page that you’ve created and see if you can see anything. If all works as planned, you’ll be confronted by a dialog box that looks something like this.

By typing in the appropriate Name and Password, the browser should proceed to display the previously hidden contents of that folder!

There’s one more thing you may need to take care of, however, depending on how you want to use the new secretstuff folder. If you’re going to use it to serve up regular webpages like index.html then you’re all done: once a user’s attempt to access the directory is authenticated, those pages will appear just as in any other directory.

You may, however, wish to just dump a bunch of files into that folder that students can access. They might be text files, or Word documents, or graphics. If this is the case, it may also be that your webserver doesn’t by default allow these files to be “indexed,” or listed, and you’ll get an error message like the one above.

This is easily fixed. In your .htaccess file—the same one that we were working on in step 2 above—add a fifth line:

AuthName "Secret Stuff"
AuthType Basic
AuthUserFile "/home/rwhite/.htpasswds/public_html/secretstuff/passwd"
Require valid-user
Options +Indexes

This line will allow this directory’s contents to be Indexed, or listed, even if there aren’t any html files to be displayed.

Now students are able to view or download those files simply by clicking on them in the browser window.