Skip to content
Merged
Show file tree
Hide file tree
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
29 changes: 12 additions & 17 deletions src/ssh/azext_ssh/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,24 @@
# regenerated.
# --------------------------------------------------------------------------

from azure.cli.core.commands.client_factory import get_mgmt_service_client


def cf_hybridconnectivity_cl(cli_ctx, *_):
from azext_ssh.vendored_sdks.hybridconnectivity import HybridConnectivityManagementAPI
return get_mgmt_service_client(cli_ctx,
HybridConnectivityManagementAPI)


def cf_endpoint(cli_ctx, *_):
return cf_hybridconnectivity_cl(cli_ctx).endpoints


def cf_connectedmachine_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_ssh.vendored_sdks.connectedmachine import ConnectedMachine
return get_mgmt_service_client(cli_ctx,
ConnectedMachine)


def cf_machine(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).machines


def cf_machine_extension(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).machine_extensions


def cf_private_link_scope(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).private_link_scopes


def cf_private_link_resource(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).private_link_resources


def cf_private_endpoint_connection(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).private_endpoint_connections
11 changes: 4 additions & 7 deletions src/ssh/azext_ssh/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
- name: Using additional ssh arguments
text: |
az ssh vm --ip 1.2.3.4 -- -A -o ForwardX11=yes
- name: Give the Resource ID of a VM to SSH using AAD issued certificates. Using the resource ID to identify the target machine is useful when there is an Azure VM and a Arc Server with the same name in the same resource group.
- name: Give the Resource Type of a VM to SSH using AAD issued certificates. Using the resource type is useful when there is an Azure VM and a Arc Server with the same name in the same resource group.
text: |
az ssh vm --resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM
az ssh vm --resource-type Microsoft.Compute --resource-group myResourceGroup --vm-name myVM
- name: Give a local user name to SSH using local user credentials on the target machine using certificate based authentication.
text: |
az ssh vm --local-user username --ip 1.2.3.4 --certificate-file cert.pub --private-key key
Expand All @@ -39,7 +39,7 @@
az ssh vm --local-user username --resource-group myResourceGroup --vm-name myVM --private-key-file key
- name: Give a local user name to SSH using local user credentials on the target machine using password based authentication.
text: |
az ssh vm --local-user username --resource-id /subscriptions/mySubsription/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/machines/myArcServer
az ssh vm --local-user username --resource-group myResourceGroup --vm-name myArcServer
"""

helps['ssh config'] = """
Expand Down Expand Up @@ -85,9 +85,6 @@
- name: Give a resource group and Arc Server Name to SSH using AAD issued certificates
text: |
az ssh arc --resource-group myResourceGroup --vm-name myArcServer
- name: Give the Resource ID of an Arc Server to SSH using AAD issued certificates
text: |
az ssh arc --resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.HybridCompute/machines/myArcServer
- name: Using a custom private key file
text: |
az ssh arc --resource-group myResourceGroup --vm-name myArcServer --private-key-file key --public-key-file key.pub
Expand All @@ -99,5 +96,5 @@
az ssh arc --resource-group myRG --vm-name myVM --local-user name --private-key-file key
- name: Give a local user name to SSH to a local user using password-based authentication
text: |
az ssh arc --resource-id /subscriptions/mySubsription/resourceGroups/myRG/providers/Microsoft.HybridCompute/machines/myArcServer --local-user username
az ssh arc --resource-group myResourceGroup --vm-name myArcServer --local-user username
"""
19 changes: 12 additions & 7 deletions src/ssh/azext_ssh/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def load_arguments(self, _):

with self.argument_context('ssh vm') as c:
c.argument('vm_name', options_list=['--vm-name', '--name', '-n'], help='The name of the VM')
c.argument('ssh_ip', options_list=['--ip', '--hostname'],
help='The public (or reachable private) IP address (or hostname) of the VM')
c.argument('resource_id', options_list=['--resource-id'], help='The Resource ID of the Azure VM or Arc Server')
c.argument('public_key_file', options_list=['--public-key-file', '-p'], help='The RSA public key file path')
c.argument('private_key_file', options_list=['--private-key-file', '-i'], help='The RSA private key file path')
c.argument('use_private_ip', options_list=['--prefer-private-ip'],
Expand All @@ -20,9 +18,12 @@ def load_arguments(self, _):
c.argument('cert_file', options_list=['--certificate-file', '-c'],
help='Path to a certificate file used for authentication when using local user credentials.')
c.argument('port', options_list=['--port'], help='SSH port')
c.argument('resource_type', options_list=['--resource-type'],
help='Resource type should be either Microsoft.Compute or Microsoft.HybridCompute',
completer=["Microsoft.HybridCompute", "Microsoft.Compute"])
c.argument('ssh_client_path', options_list=['--ssh-client-path'],
help='Path to ssh executable. Default to ssh pre-installed if not provided.')
c.argument('delete_privkey', options_list=['--delete-private-key'],
c.argument('delete_credentials', options_list=['--force-delete-credentials', '--delete-private-key'],
help=('This is an internal argument. This argument is used by Azure Portal to provide a one click '
'SSH login experience in Cloud shell.'),
deprecate_info=c.deprecate(hide=True), action='store_true')
Expand All @@ -32,7 +33,6 @@ def load_arguments(self, _):
c.argument('config_path', options_list=['--file', '-f'], help='The file path to write the SSH config to')
c.argument('vm_name', options_list=['--vm-name', '--name', '-n'], help='The name of the VM')
c.argument('ssh_ip', options_list=['--ip'], help='The public IP address (or hostname) of the VM')
c.argument('resource_id', options_list=['--resource-id'], help='The Resource ID of the Azure VM or Arc Server')
c.argument('public_key_file', options_list=['--public-key-file', '-p'], help='The RSA public key file path')
c.argument('private_key_file', options_list=['--private-key-file', '-i'], help='The RSA private key file path')
c.argument('use_private_ip', options_list=['--prefer-private-ip'],
Expand All @@ -41,13 +41,19 @@ def load_arguments(self, _):
help='The username for a local user')
c.argument('overwrite', action='store_true', options_list=['--overwrite'],
help='Overwrites the config file if this flag is set')
c.argument('credentials_folder', options_list=['--keys-destination-folder', '--keys-dest-folder'],
help='Folder where new generated keys will be stored.')
c.argument('port', options_list=['--port'], help='Port to connect to on the remote host.')
c.argument('resource_type', options_list=['--resource-type'],
help='Resource type should be either Microsoft.Compute or Microsoft.HybridCompute')
c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file')

with self.argument_context('ssh cert') as c:
c.argument('cert_path', options_list=['--file', '-f'],
help='The file path to write the SSH cert to, defaults to public key path with -aadcert.pub appened')
c.argument('public_key_file', options_list=['--public-key-file', '-p'], help='The RSA public key file path')
c.argument('public_key_file', options_list=['--public-key-file', '-p'],
help='The RSA public key file path. If not provided, '
'generated key pair is stored in the same directory as --file.')

with self.argument_context('ssh arc') as c:
c.argument('vm_name', options_list=['--vm-name', '--name', '-n'], help='The name of the Arc Server')
Expand All @@ -56,11 +62,10 @@ def load_arguments(self, _):
c.argument('local_user', options_list=['--local-user'],
help='The username for a local user')
c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file')
c.argument('resource_id', options_list=['--resource-id'], help='The Resource ID of the Arc Server')
c.argument('port', options_list=['--port'], help='Port to connect to on the remote host.')
c.argument('ssh_client_path', options_list=['--ssh-client-path'],
help='Path to ssh executable. Default to ssh pre-installed if not provided.')
c.argument('delete_privkey', options_list=['--delete-private-key'],
c.argument('delete_credentials', options_list=['--force-delete-credentials', '--delete-private-key'],
help=('This is an internal argument. This argument is used by Azure Portal to provide a one click '
'SSH login experience in Cloud shell.'),
deprecate_info=c.deprecate(hide=True), action='store_true')
Expand Down
9 changes: 7 additions & 2 deletions src/ssh/azext_ssh/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

CLIENT_PROXY_VERSION = "1.3.017131"
CLIENT_PROXY_RELEASE = "release10-09-21"
CLIENT_PROXY_VERSION = "1.3.017634"
CLIENT_PROXY_RELEASE = "release01-11-21"
CLIENT_PROXY_STORAGE_URL = "https://sshproxysa.blob.core.windows.net"
CLEANUP_TOTAL_TIME_LIMIT_IN_SECONDS = 120
CLEANUP_TIME_INTERVAL_IN_SECONDS = 10
CLEANUP_AWAIT_TERMINATION_IN_SECONDS = 30
PROXY_UNSUPPORTED_ARCH_FAULT_TYPE = 'client-proxy-unsupported-architecture-error'
PROXY_UNSUPPORTED_OS_FAULT_TYPE = 'client-proxy-unsupported-os-error'
PROXY_DOWNLOAD_FAILED_FAULT_TYPE = 'client-proxy-download-failed-error'
LIST_CREDENTIALS_FAILED_FAULT_TYPE = 'get-relay-information-failed-error'
Loading