Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --server-ssh-key for join command #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func MakeJoin() *cobra.Command {
command.Flags().String("server-user", "root", "Server username for SSH login (Default to --user)")

command.Flags().String("ssh-key", "~/.ssh/id_rsa", "The ssh key to use for remote login")
command.Flags().String("server-ssh-key", "", "The ssh key of an existing k3s server")

command.Flags().Int("ssh-port", 22, "The port on which to connect for ssh")
command.Flags().Int("server-ssh-port", 22, "The port on which to connect to server for ssh (Default to --ssh-port)")
command.Flags().Bool("skip-install", false, "Skip the k3s installer")
Expand Down Expand Up @@ -153,6 +155,11 @@ func MakeJoin() *cobra.Command {
}

sshKey, _ := command.Flags().GetString("ssh-key")
serverSshKey, _ := command.Flags().GetString("server-ssh-key")
if len(serverSshKey) == 0 {
serverSshKey = sshKey
}

server, err := command.Flags().GetBool("server")
if err != nil {
return err
Expand Down Expand Up @@ -195,11 +202,12 @@ func MakeJoin() *cobra.Command {
sudoPrefix = "sudo "
}
sshKeyPath := expandPath(sshKey)
serverSshKeyPath := expandPath(serverSshKey)

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

sshOperator, sshOperatorDone, errored, err := connectOperator(serverUser, address, sshKeyPath)
sshOperator, sshOperatorDone, errored, err := connectOperator(serverUser, address, serverSshKeyPath)
if errored {
return err
}
Expand Down