headscale client extract last line only
diff --git a/core/headscale/client.go b/core/headscale/client.go
index 9147629..edc36ff 100644
--- a/core/headscale/client.go
+++ b/core/headscale/client.go
@@ -3,6 +3,7 @@
 import (
 	"fmt"
 	"os/exec"
+	"strings"
 )
 
 type client struct {
@@ -26,8 +27,11 @@
 	// TODO(giolekva): make expiration configurable, and auto-refresh
 	cmd := exec.Command("headscale", c.config, "--user", user, "preauthkeys", "create", "--reusable", "--expiration", "365d")
 	out, err := cmd.Output()
+	if err != nil {
+		return "", err
+	}
 	fmt.Println(string(out))
-	return string(out), err
+	return extractLastLine(string(out))
 }
 
 func (c *client) enableRoute(id string) error {
@@ -37,3 +41,14 @@
 	fmt.Println(string(out))
 	return err
 }
+
+func extractLastLine(s string) (string, error) {
+	items := strings.Split(s, "\n")
+	for i := len(items) - 1; i >= 0; i-- {
+		t := strings.TrimSpace(items[i])
+		if t != "" {
+			return t, nil
+		}
+	}
+	return "", fmt.Errorf("All lines are empty")
+}