|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 | +# -------------------------------------------------------------------------------------------- |
| 6 | + |
| 7 | +from knack.help_files import helps # pylint: disable=unused-import |
| 8 | + |
| 9 | + |
| 10 | +helps['sftp'] = """ |
| 11 | + type: group |
| 12 | + short-summary: Commands to connect to Azure Storage Accounts via SFTP |
| 13 | + long-summary: | |
| 14 | + These commands allow you to generate certificates and connect to Azure Storage Accounts using SFTP. |
| 15 | +
|
| 16 | + PREREQUISITES: |
| 17 | + - Azure Storage Account with SFTP enabled |
| 18 | + - Appropriate RBAC permissions (Storage Blob Data Contributor or similar) |
| 19 | + - Azure CLI authentication (az login) |
| 20 | + - Network connectivity to Azure Storage endpoints |
| 21 | +
|
| 22 | + The SFTP extension provides two main capabilities: |
| 23 | + 1. Certificate generation using Azure AD authentication (similar to 'az ssh cert') |
| 24 | + 2. Fully managed SFTP connections to Azure Storage with automatic credential handling |
| 25 | +
|
| 26 | + AUTHENTICATION MODES: |
| 27 | + - Fully managed: No credentials needed - automatically generates SSH certificate |
| 28 | + - Certificate-based: Use existing SSH certificate file |
| 29 | + - Key-based: Use SSH public/private key pair (generates certificate automatically) |
| 30 | +
|
| 31 | + This extension closely follows the patterns established by the SSH extension. |
| 32 | +""" |
| 33 | + |
| 34 | +helps['sftp cert'] = """ |
| 35 | + type: command |
| 36 | + short-summary: Generate SSH certificate for SFTP authentication |
| 37 | + long-summary: | |
| 38 | + Generate an SSH certificate that can be used for authenticating to Azure Storage SFTP endpoints. |
| 39 | + This uses Azure AD authentication to generate a certificate similar to 'az ssh cert'. |
| 40 | +
|
| 41 | + CERTIFICATE NAMING: |
| 42 | + - Generated certificates have '-aadcert.pub' suffix (e.g., id_rsa-aadcert.pub) |
| 43 | + - Certificates are valid for a limited time (typically 1 hour) |
| 44 | + - Private keys are generated with 'id_rsa' name when key pair is created |
| 45 | +
|
| 46 | + The certificate can be used with 'az sftp connect' or with standard SFTP clients. |
| 47 | + examples: |
| 48 | + - name: Generate a certificate using an existing public key |
| 49 | + text: az sftp cert --public-key-file ~/.ssh/id_rsa.pub --file ~/my_cert.pub |
| 50 | + - name: Generate a certificate and create a new key pair in the same directory |
| 51 | + text: az sftp cert --file ~/my_cert.pub |
| 52 | + - name: Generate a certificate with custom SSH client folder |
| 53 | + text: az sftp cert --file ~/my_cert.pub --ssh-client-folder "C:\\Program Files\\OpenSSH" |
| 54 | +""" |
| 55 | + |
| 56 | +helps['sftp connect'] = """ |
| 57 | + type: command |
| 58 | + short-summary: Connect to Azure Storage Account via SFTP |
| 59 | + long-summary: | |
| 60 | + Establish an SFTP connection to an Azure Storage Account. |
| 61 | +
|
| 62 | + AUTHENTICATION MODES: |
| 63 | + 1. Fully managed (RECOMMENDED): Run without credentials - automatically generates SSH certificate |
| 64 | + and establishes connection. Credentials are cleaned up after use. |
| 65 | +
|
| 66 | + 2. Certificate-based: Use existing SSH certificate file. Certificate must be generated with |
| 67 | + 'az sftp cert' or compatible with Azure AD authentication. |
| 68 | +
|
| 69 | + 3. Key-based: Provide SSH keys - command will generate certificate automatically from your keys. |
| 70 | +
|
| 71 | + CONNECTION DETAILS: |
| 72 | + - Username format: {storage-account}.{azure-username} |
| 73 | + - Port: Uses SSH default (typically 22) unless specified with --port |
| 74 | + - Endpoints resolved automatically based on Azure cloud environment: |
| 75 | + * Azure Public: {storage-account}.blob.core.windows.net |
| 76 | + * Azure China: {storage-account}.blob.core.chinacloudapi.cn |
| 77 | + * Azure Government: {storage-account}.blob.core.usgovcloudapi.net |
| 78 | +
|
| 79 | + SECURITY: |
| 80 | + - Generated credentials are automatically cleaned up after connection |
| 81 | + - Temporary files stored in secure temporary directories |
| 82 | + - Certificate validity is checked and renewed if expired |
| 83 | + examples: |
| 84 | + - name: Connect with automatic certificate generation (fully managed - RECOMMENDED) |
| 85 | + text: az sftp connect --storage-account mystorageaccount |
| 86 | + - name: Connect to storage account with existing certificate |
| 87 | + text: az sftp connect --storage-account mystorageaccount --certificate-file ~/my_cert.pub |
| 88 | + - name: Connect with existing SSH key pair |
| 89 | + text: az sftp connect --storage-account mystorageaccount --public-key-file ~/.ssh/id_rsa.pub --private-key-file ~/.ssh/id_rsa |
| 90 | + - name: Connect with custom port |
| 91 | + text: az sftp connect --storage-account mystorageaccount --port 2222 |
| 92 | + - name: Connect with additional SFTP arguments for debugging |
| 93 | + text: az sftp connect --storage-account mystorageaccount --sftp-args "-v" |
| 94 | + - name: Connect with custom SSH client folder (Windows) |
| 95 | + text: az sftp connect --storage-account mystorageaccount --ssh-client-folder "C:\\Program Files\\OpenSSH" |
| 96 | + - name: Run batch commands after connecting |
| 97 | + text: az sftp connect --storage-account mystorageaccount --batch-commands "ls\\nget file.txt\\nbye" |
| 98 | +""" |
0 commit comments