Skip to content

Commit 76ce3d4

Browse files
committed
Add --server-ssh-key for join command
Signed-off-by: JerryKhw <[email protected]>
1 parent 0e44269 commit 76ce3d4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/join.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func MakeJoin() *cobra.Command {
5959
command.Flags().String("server-user", "root", "Server username for SSH login (Default to --user)")
6060

6161
command.Flags().String("ssh-key", "~/.ssh/id_rsa", "The ssh key to use for remote login")
62+
command.Flags().String("server-ssh-key", "", "The ssh key of an existing k3s server")
63+
6264
command.Flags().Int("ssh-port", 22, "The port on which to connect for ssh")
6365
command.Flags().Int("server-ssh-port", 22, "The port on which to connect to server for ssh (Default to --ssh-port)")
6466
command.Flags().Bool("skip-install", false, "Skip the k3s installer")
@@ -154,6 +156,11 @@ func MakeJoin() *cobra.Command {
154156
}
155157

156158
sshKey, _ := command.Flags().GetString("ssh-key")
159+
serverSshKey, _ := command.Flags().GetString("server-ssh-key")
160+
if len(serverSshKey) == 0 {
161+
serverSshKey = sshKey
162+
}
163+
157164
server, err := command.Flags().GetBool("server")
158165
if err != nil {
159166
return err
@@ -196,11 +203,12 @@ func MakeJoin() *cobra.Command {
196203
sudoPrefix = "sudo "
197204
}
198205
sshKeyPath := expandPath(sshKey)
206+
serverSshKeyPath := expandPath(serverSshKey)
199207

200208
if len(nodeToken) == 0 {
201209
address := fmt.Sprintf("%s:%d", serverHost, serverPort)
202210

203-
sshOperator, sshOperatorDone, errored, err := connectOperator(serverUser, address, sshKeyPath)
211+
sshOperator, sshOperatorDone, errored, err := connectOperator(serverUser, address, serverSshKeyPath)
204212
if errored {
205213
return err
206214
}

0 commit comments

Comments
 (0)