Skip to content

Add support for custom ports when using ssh tunnel #9173

@mikeblakeuk

Description

@mikeblakeuk

Add support for custom ports to bastion ssh.

The use case is that we want to connect to a Private AKS cluster.
We have bastion setup and VM we connect to.

It would be nice to force the custom ports, and let az do the ssh key management.

az network bastion ssh --name "bastion" --resource-group "$group" --target-resource-id "$vmId" --resource-port 22 --auth-type AAD -- -L $customPort:our-cluster-abcde.dev-eus.privatelink.eastus.azmk8s.io:443

https://github.com/Azure/azure-cli-extensions/blob/a2dc8d7661670d56c92115092725214710f4a9ab/src/bastion/azext_bastion/custom.py

Instead we have to create the tunnel, the create ssh keys, then run ssh with port forwarding.

kubectl config set "clusters.$name.server" "https://localhost:$clusterPort"

az network bastion tunnel --name bastion --resource-group $group--target-resource-id '$vmId' --resource-port 22 --port $bastionPort

az ssh config --ip localhost --port $bastionPort --file $sshConfigPath --overwrite --yes-without-prompt #--debug

ssh -NTf -v $sshParams localhost -p $bastionPort -F $sshConfigPath -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botNetworkNetwork - BastionService AttentionThis issue is responsible by Azure service team.VM SSHcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions