Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #18 from iuliand-db/issue/file-not-found-ssh
Browse files Browse the repository at this point in the history
Show a nicer error message when SSH keys are not found
  • Loading branch information
iuliand-db authored Jul 10, 2020
2 parents 82df2cb + 1dfaf93 commit b658e1c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions launcher/src/EnsureInstanceRunning.scala
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,22 @@ case class EnsureInstanceRunning(userName: String = os.proc("whoami").call().out
val (sshPublicKey, sshPrivateKey) = (sshPublicKeyOpt, sshPrivateKeyOpt) match{
case (Some(pub), Some(priv)) => (pub, priv)
case (None, None) => (os.home / ".ssh" / "id_rsa.pub", os.home / ".ssh" / "id_rsa")
case _ => throw new Exception(
case _ =>
System.err.println(
"--ssh-private-key and --ssh-public-key must be passed in together, or not at all. " +
"Make sure you set both if you want to configure them"
)
"Make sure you set both if you want to configure them")
System.exit(1)
(os.root, os.root) // just to satisfy the type-checker, this line is never executed
}

if (!os.exists(sshPublicKey)) {
Console.err.println(s"Could not find ssh public key in $sshPublicKey")
System.exit(1)
}

if (!os.exists(sshPrivateKey)) {
Console.err.println(s"Could not find ssh private key in $sshPrivateKey")
System.exit(1)
}

val pubKey = os.read(sshPublicKey)
Expand Down

0 comments on commit b658e1c

Please sign in to comment.