diff --git a/cmd/flux/bootstrap_github.go b/cmd/flux/bootstrap_github.go
index e40efd0f679f9756ceaa4364ef7214c8d511e86d..56f6287850602a83fa53b719979895114977e198 100644
--- a/cmd/flux/bootstrap_github.go
+++ b/cmd/flux/bootstrap_github.go
@@ -248,7 +248,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
 		if err != nil {
 			return fmt.Errorf("git URL parse failed: %w", err)
 		}
-		secretOpts.SSHHostname = u.Hostname()
+		secretOpts.SSHHostname = u.Host
 		secretOpts.PrivateKeyAlgorithm = sourcesecret.RSAPrivateKeyAlgorithm
 		secretOpts.RSAKeyBits = 2048
 	}
diff --git a/cmd/flux/bootstrap_gitlab.go b/cmd/flux/bootstrap_gitlab.go
index 15088d318b63cd5e347da0d9ab3f0911bf9fdb93..8acf93aa5d1cf2e159e988932d759a5c2e8a3289 100644
--- a/cmd/flux/bootstrap_gitlab.go
+++ b/cmd/flux/bootstrap_gitlab.go
@@ -235,7 +235,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
 		if err != nil {
 			return fmt.Errorf("git URL parse failed: %w", err)
 		}
-		secretOpts.SSHHostname = u.Hostname()
+		secretOpts.SSHHostname = u.Host
 		secretOpts.PrivateKeyAlgorithm = sourcesecret.RSAPrivateKeyAlgorithm
 		secretOpts.RSAKeyBits = 2048
 	}
diff --git a/cmd/flux/create_secret_git.go b/cmd/flux/create_secret_git.go
index b84bcbbde968029a4b4d4433efa7b88849b0eae7..d24faadcbd2f66b3306b7a9d280073d589dab00e 100644
--- a/cmd/flux/create_secret_git.go
+++ b/cmd/flux/create_secret_git.go
@@ -129,7 +129,7 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
 	}
 	switch u.Scheme {
 	case "ssh":
-		opts.SSHHostname = u.Hostname()
+		opts.SSHHostname = u.Host
 		opts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(secretGitArgs.keyAlgorithm)
 		opts.RSAKeyBits = int(secretGitArgs.rsaBits)
 		opts.ECDSACurve = secretGitArgs.ecdsaCurve.Curve
diff --git a/cmd/flux/create_source_git.go b/cmd/flux/create_source_git.go
index 2ee13daa40e07832741e646d0307fc37014ee591..e245af6ba1341b8d5c7715b1aa8898cb68a5e161 100644
--- a/cmd/flux/create_source_git.go
+++ b/cmd/flux/create_source_git.go
@@ -215,7 +215,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
 		}
 		switch u.Scheme {
 		case "ssh":
-			secretOpts.SSHHostname = u.Hostname()
+			secretOpts.SSHHostname = u.Host
 			secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(sourceGitArgs.keyAlgorithm)
 			secretOpts.RSAKeyBits = int(sourceGitArgs.keyRSABits)
 			secretOpts.ECDSACurve = sourceGitArgs.keyECDSACurve.Curve