Skip to content

Commit

Permalink
Fix hcloud server ssh with flexible network options (#396)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Kämmerling <[email protected]>
  • Loading branch information
LKaemmerling authored Jul 13, 2022
1 parent 702233e commit aa62e36
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/cmd/server/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ func runSSH(cli *state.State, cmd *cobra.Command, args []string) error {

ipAddress := server.PublicNet.IPv4.IP
if useIPv6 {
if server.PublicNet.IPv6.IsUnspecified() {
return fmt.Errorf("server %s does not have a assigned primary ipv6", idOrName)
}
ipAddress = server.PublicNet.IPv6.Network.IP
// increment last byte to get the ::1 IP, which is routed
ipAddress[15]++
} else {
if server.PublicNet.IPv4.IsUnspecified() {
return fmt.Errorf("server %s does not have a assigned primary ipv4", idOrName)
}
}

sshArgs := []string{"-l", user, "-p", strconv.Itoa(port), ipAddress.String()}
Expand Down

0 comments on commit aa62e36

Please sign in to comment.