Bulk Upload SSH Keys

The API will upload SSH keys (userKeys or hostKeys) in public profile.

Before you begin

Before attempting to uploading SSH keys, the user has to ensure the following:
  • ACF permission is available. This can be verified under Plaform > Role > Authorized Functions.

Request Structure

Endpoint: /ssh/keys/upload
Type: POST
Sample URL: https://<IP/HostName/TenantName>:<GWPORT>/avxapi/ssh/keys/upload?gwsource=external

To understand the elements of the sample URL, click here.

Headers:
Content-Type: application/json
Table 1. Request Parameters
Name Description
sessionId

Header

(Mandatory) Session ID received after login.

Type: String

Constraints: Required if username and password are not provided.

username

Header

(Mandatory) AppViewX login username

Type: String

Constraints: Required if sessionId is not provided.

password

Header

(Mandatory) AppViewX login password

Type: String

Constraints: Required if sessionId is not provided.

Content-Type

Header

(Mandatory) Specifies the nature of the data in the payload

Type: String

Constraints: The value of the param should be ‘application/json’.

gwsource

Query

(Mandatory) Source from which the request is triggered. (E.g. external)

Type: String

Payload

Body

(Mandatory) Contains all the parameters to be sent in the request body for the post request

Type: Payload

Payload

Name Description
keyType (Mandatory) Either userKeys or hostKeys in which the key location it belngs to.

Type: String

keyRequests (Mandatory) List of ssh keys details.

Type: keyRequests

Table 2. keyRequests
Name Description
publicKey (Mandatory) Base64 encoded public key content.

Type: String

privateKey (Mandatory) Base64 encoded private key content.

Type: String

keyName (Optional) Name of the key (optional appviewx will created key name if not given - Created-<dateFormat>-<sequenceNumber>).

Type: String

keyGroup (Optional) Name of the group in which the key needs to be mapped (optional appviewx will assign the key to Default_Key_Group if not given).

Type: String

Response Structure

200 OK returns string of type application/json with the following body params.

Table 3. Response Parameters
Name Description
response Contains the response attributes for the host keys

Type: response

message Success message of the action or failure description in case of error. Will be non-null for failure response

Type: String

appStatusCode Application-specific status code for the response. Will be non-null for failure response

Type: String

tags More info in case of failure response
Table 4. Response
Name Description
status

The result of the upload operation. Example: "Uploaded Successfully"

requestId A unique identifier (UUID) for the upload request. This ID is used to track or fetch the status/details of the upload using the GET: ssh/keys/upload/list API.

Status Codes

Table 5. Status Codes and Description
HTTP Status code appStatusCode Message and Possible remediation
200 OK NA Uploaded successfully
401 Unauthorized AVX_GW_003 Authentication failed, reason - Invalid Credentials

Possible remediation: Ensure that valid username and password or valid sessionId is provided as the header param.

400 Bad Request AVX-VLDTN-001 Mandatory field is missing or invalid values specified - <<field name>>

Possible remediation: Check and ensure that valid value is provided for <<field name>> field in the request.

Sample Request/Response

Use Case

To upload SSH keys (userKeys or hostKeys) in public profile, using /ssh/keys/upload API.

Request URL
https://<IP/HostName/TenantName>:<GWPORT>/avxapi/ssh/keys/upload?keysFrom=rotatedInventory&gwsource=externalhttps://<IP/HostName/TenantName>:<GWPORT>/avxapi/ssh/search/hostKeys?keysFrom=rotatedInventory&gwsource=external
Sample Request
{
    "keyType": "hostKeys",
    "keyRequests": [
        {
            "publicKey": "c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFEcnBXNExCZngzS0xFdHFHTWlRZktHbUNGRzRHWUFLcE8xSndudnhlOHNJWkxCaVo1QTZEN3QzcStPejlKc1cvQ2hwRGYvOGlMZUFwVmpsb3NaVDNvRmpBaEpFNHJLeWZsUUJUdVVnUUdGNE1PRUhkL0dZZnN6VjZVSEROMU1ucUlsMFNEYjNlVkVzY0gxVVRYQ3lLTVpnNUtrVVRiRWdSTm00Sjdna3NXeG9na0xVaHR2aG4yL1BXUkZGVGJLQTQ2R1VLZktObVR6L2ZXd2dhelpEQUxLcktPYTZOMnNkek1XOU9TMGFvWmV0a1hJL3BJdThYWU1KNEhKN2VuOXpGWWEveEdUT05GSlNHbWdlY3ptNHREaU95dzhWRWhzdjZ6Y2ZzeGNQbGxpK3pWWUJ3SSt0SjM0emVjQ2VaNEliNFhrQzdhTmQ4VjVVcmlXenh3VFdFVWQgYXBwdmlld3hAcGUtc3NoLWFwdngtbjcK"
        }
    ]
}
Sample Response
{
    "response": {
        "status": "Uploaded Successfully",
        "requestId": "3f01c360-0abd-4e3d-bbdc-258690f5ce2e"
    },
    "message": null,
    "appStatusCode": null,
    "tags": {},
    "headers": null
}

Reference

Understanding the sample URL:
  • IP/HostName/TenantName: Replace with the actual IP address, hostname, or tenant name based on the specific configuration in AppViewX.
    • IP: A unique identifier assigned to each device connected to a computer network that uses the Internet Protocol for communication

      The IP address will be included in the endpoint URL for an on-prem deployment.

    • HostName: A human-readable label assigned to a device (host) on a network

      The hostname will be included in the endpoint URL for an on-prem deployment.

    • TenantName: An identifier label for a tenant given to indicate which tenant's data the API request will access/modify

      The tenant name will be included in the endpoint URL for a SaaS deployment.

  • GWPORT: AppViewX gateway port
    A gateway port refers to a network port through which data is sent and received to communicate with a gateway in an on-prem deployment.
    Note: GWPORT is not required for SaaS setups.

    Example: 31443

  • avxapi: Path parameter value (static) that is part of the endpoint's URL
  • Endpoint: Endpoint of the API, for example: /ssh/host/create
  • gwsource: Source or origin of a gateway, for example: external.

What's Next