Azure / Azure/azure-cli-extensions

Add support for custom ports when using ssh tunnel

Open
#9,173 4 comments 0 reactions 1 assignee Claimed by @necusjz View on GitHub
Auto-Assign customer-reported Network Network - Bastion question Service Attention VM SSH
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.