[testrunner] Expect SSH key as a filepath

Change-Id: I99f7e25adba2e9bffe292a18de9fda46dac29255
diff --git a/cmd/testrunner/main.go b/cmd/testrunner/main.go
index 8470a8d..46375e3 100644
--- a/cmd/testrunner/main.go
+++ b/cmd/testrunner/main.go
@@ -10,6 +10,7 @@
 	"flag"
 	"fmt"
 	"io"
+	"io/ioutil"
 	"log"
 	"os"
 	"time"
@@ -91,13 +92,13 @@
 
 	// Execute.
 	nodename := os.Getenv(nodenameEnvVar)
-	sshKey := os.Getenv(sshKeyEnvVar)
-	if err := execute(tests, output, nodename, sshKey); err != nil {
+	sshKeyFile := os.Getenv(sshKeyEnvVar)
+	if err := execute(tests, output, nodename, sshKeyFile); err != nil {
 		log.Fatal(err)
 	}
 }
 
-func execute(tests []testsharder.Test, output *Output, nodename, sshKey string) error {
+func execute(tests []testsharder.Test, output *Output, nodename, sshKeyFile string) error {
 	var linux, mac, fuchsia, unknown []testsharder.Test
 	for _, test := range tests {
 		switch test.OS {
@@ -129,18 +130,22 @@
 		return err
 	}
 
-	return runFuchsiaTests(fuchsia, output, nodename, sshKey)
+	return runFuchsiaTests(fuchsia, output, nodename, sshKeyFile)
 }
 
-func runFuchsiaTests(tests []testsharder.Test, output *Output, nodename, sshKey string) error {
+func runFuchsiaTests(tests []testsharder.Test, output *Output, nodename, sshKeyFile string) error {
 	if len(tests) == 0 {
 		return nil
 	} else if nodename == "" {
 		return fmt.Errorf("%s must be set", nodenameEnvVar)
-	} else if sshKey == "" {
+	} else if sshKeyFile == "" {
 		return fmt.Errorf("%s must be set", sshKeyEnvVar)
 	}
 
+	sshKey, err := ioutil.ReadFile(sshKeyFile)
+	if err != nil {
+		return err
+	}
 	tester, err := NewFuchsiaTester(nodename, sshKey)
 	if err != nil {
 		return fmt.Errorf("failed to initialize fuchsia tester: %v", err)
diff --git a/cmd/testrunner/tester.go b/cmd/testrunner/tester.go
index e5bd008..8e92978 100644
--- a/cmd/testrunner/tester.go
+++ b/cmd/testrunner/tester.go
@@ -54,8 +54,8 @@
 	client *ssh.Client
 }
 
-func NewSSHTester(nodename, sshKey string) (*SSHTester, error) {
-	config, err := botanist.DefaultSSHConfig([]byte(sshKey))
+func NewSSHTester(nodename string, sshKey []byte) (*SSHTester, error) {
+	config, err := botanist.DefaultSSHConfig(sshKey)
 	if err != nil {
 		return nil, fmt.Errorf("failed to create an SSH client config: %v", err)
 	}
@@ -97,7 +97,7 @@
 
 // NewFuchsiaTester creates a FuchsiaTester object and starts a log_listener process on
 // the remote device. The log_listener output can be read from SysLogOutput().
-func NewFuchsiaTester(nodename, sshKey string) (*FuchsiaTester, error) {
+func NewFuchsiaTester(nodename string, sshKey []byte) (*FuchsiaTester, error) {
 	delegate, err := NewSSHTester(nodename, sshKey)
 	if err != nil {
 		return nil, err
diff --git a/cmd/testrunner/tester_test.go b/cmd/testrunner/tester_test.go
index 774aa0b..c393df8 100644
--- a/cmd/testrunner/tester_test.go
+++ b/cmd/testrunner/tester_test.go
@@ -7,6 +7,7 @@
 import (
 	"bytes"
 	"context"
+	"io/ioutil"
 	"os"
 	"strings"
 	"testing"
@@ -72,10 +73,14 @@
 	if nodename == "" {
 		t.Fatal("FUCHSIA_NODENAME not set")
 	}
-	sshKey := os.Getenv("FUCHSIA_SSH_KEY")
-	if sshKey == "" {
+	sshKeyFile := os.Getenv("FUCHSIA_SSH_KEY")
+	if sshKeyFile == "" {
 		t.Fatal("FUCHSIA_SSH_KEY not set")
 	}
+	sshKey, err := ioutil.ReadFile(sshKeyFile)
+	if err != nil {
+		t.Fatalf("could not read file %q", sshKeyFile)
+	}
 
 	cases := []struct {
 		name   string