Recovering from losing all ssh access Ubuntu 16.04

So I managed to lock myself out of my own computer.

I installed mysecureshell and didn’t realize that it disables shell access, which was my only way to control the machine.

So what did I do?

  1. Recover the root password
    1. Boot into recovery mode
      1. Restart Ubuntu and when the Grub menu comes up
      2. Select Ubuntu “Advanced options”
      3. Then select “Drop to root shell prompt”
    2. Remount /
      mount -rw -o remount /
    3. Reset password
      sudo passwd
    4. Reboot
  2. Re-enable SSH
    1. Now you should be able to ssh remotely as root.  So ssh into the machine as root and provide the password
    2. vi /etc/ssh/sftp_config
    3. under the <Default> section make sure that you have the following
      Shell                   /bin/bash
    4. Restart mysecureshell
      service mysecureshell restart

When mysecureshell disables shell on Ubuntu 16.04…

When I installed mysecureshell to setup sftp for my Ubuntu 16.04 server, it decided to do a lot of other things like…disable ssh access.

I don’t know why they don’t tell you this in screaming caps to begin with.

But a quick look at the Shell directive ( reveals that indeed if you install mysecureshell, it will turn it off by default.

I’m not necessarily opposed to that as a practice but they should make that really obvious as it took me quite some time to figure out what it was that made mysecureshell turn it off in the first place.

I installed mysecureshell via apt-get and configure sftp but then suddenly I got:

$ ssh user@server
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-59-generic x86_64)

 * Documentation:
 * Management:
 * Support:

22 packages can be updated.
0 updates are security updates.

Last login: Thu Feb 2 01:27:02 2017 from
Shell access is disabled !Connection to server closed.

What gives?  I didn’t change SSH access…I added SFTP.  Or did I?  So yes, installing mysecureshell will in fact disable SSH access by default.

Adding the directive

Shell /bin/bash

to the <Default> parent tag will re-enable ssh access.

How to write html test reports while keeping console output for ScalaTest

Recently I decided that I wanted to have html reports of my ScalaTest unit tests.  What I didn’t realize was that it would *remove* my console output!

When I first added html reports, I discovered that the required a dependency I wasn’t aware of: pegdown.


Adding html reports was as easy as setting it in the testOptions:

(testOptions in Test) += Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/report")

As I mentioned above, this caused the following error:

java.lang.NoClassDefFoundError: org/pegdown/PegDownProcessor

So I added the latest version of PegDown to my build.sbt and set its scope to test:

"org.pegdown" % "pegdown" % "1.6.0" % "test"

But then I discovered that I wasn’t getting any console output for my tests!

The answer is to simply add both to your testOptions sequence:

testOptions in Test ++= Seq(Tests.Argument(TestFrameworks.ScalaTest, "-o"), Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/test-reports"))


How to create an enumeration in Scala with custom values and names

There has been some back and forth about whether Scala devs should even be creating enumerations to begin with.  (

But in the case you wanted to, here’s how to do it:

object MyEnumeration extends Enumeration {
  type MyEnumeration = Value
  val First = Value(1, "Custom Name")
  val Second = Value(2, "Custom Name2")
  val Third = Value(3, "Custom Name3")

Happy Coding!


How to suppress Scalastyle rules

Sometimes Scalastyle will bark at you for reasons that aren’t always constructive.  For example, the magic number rule is generally a good one except when you are trying to create an enumeration with a particular indexing.  Because Scala will automatically 0-base the enumeration entries, if you wanted to 1-base them, you will need to reindex them.  But then this means you need to set them as below:

object MyEnumeration extends Enumeration {
  type MyEnumeration = Value
  val `First` = Value(1)
  val `Second` = Value(2)
  val `Third` = Value(3)

As you can see, the numbers 1, 2, 3 are considered ‘magic numbers’.

So the way to suppress the rule is to a) find the offending rule id (in this case magic.number) then b) make the following change:

object MyEnumeration extends Enumeration {
  // scalastyle:off magic.number
  type MyEnumeration = Value
  val `First` = Value(1)
  val `Second` = Value(2)
  val `Third` = Value(3)
 // scalastyle:on magic.number

Happy coding!

How to set up a git commit message template

  1. Create a template in your user directory. Name the file .gitmessage
    vi ~/.gitmessage
  2. Add the following as your template:
     [commit message title]
     Test Plan:
  3. Then set it as part of your global configuration:
    git config —global commit.template = ~/.gitmessage