Delete users from an SFTP server

This document shows how to remove a user from a Cloud FTP server.

Required roles

To get the permission that you need to delete SFTP users, ask your administrator to grant you the FTP Admin (roles/ftp.admin) IAM role on your project. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the ftp.users.delete permission, which is required to delete SFTP users.

You might also be able to get this permission with custom roles or other predefined roles.

Delete an SFTP user

gcloud

  1. Delete the service account that accesses Cloud Storage resources on behalf of the user:

    1. Get the email address of the user's service account. For example, USERNAME-sa@PROJECT_ID.iam.gserviceaccount.com. For steps, see Get details about a user.

    2. Delete the service account:

      gcloud iam service-accounts delete SERVICE_ACCOUNT

      Replace SERVICE_ACCOUNT with the email address of the service account.

  2. To delete the user from an SFTP server, run the gcloud alpha storage ftp users delete command.

    Before using any of the command data below, make the following replacements:

    • USERNAME: the SFTP user's username.
    • LOCATION_ID: the location of the server, such as us-west1.
    • SERVER_ID: the server ID.

    Execute the following command:

    Linux, macOS, or Cloud Shell

    gcloud alpha storage ftp users delete USERNAME --location=LOCATION_ID \
        --server=SERVER_ID

    Windows (PowerShell)

    gcloud alpha storage ftp users delete USERNAME --location=LOCATION_ID `
        --server=SERVER_ID

    Windows (cmd.exe)

    gcloud alpha storage ftp users delete USERNAME --location=LOCATION_ID ^
        --server=SERVER_ID
    It takes a few seconds for the user to be deleted.

REST

  1. Delete the service account that accesses Cloud Storage resources on behalf of the user:

    1. Get the email address of the user's service account. For example, USERNAME-sa@PROJECT_ID.iam.gserviceaccount.com. For steps, see Get details about a user.

    2. Delete the service account:

      gcloud iam service-accounts delete SERVICE_ACCOUNT

      Replace SERVICE_ACCOUNT with the email address of the service account.

  2. To delete the user from an SFTP server, use the servers.users.delete method.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: the Google Cloud project ID.
    • LOCATION_ID: the location of the server, such as us-west1.
    • SERVER_ID: the server ID.
    • USERNAME: the SFTP user's username.

    HTTP method and URL:

    DELETE https://ftp.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/servers/SERVER_ID/users/USERNAME

    To send your request, expand one of these options:

    The response identifies a long-running operation. It takes a few seconds for the user to be deleted.

What's next