This document shows how to create an internal SFTP server by using Cloud FTP. An internal SFTP server can be accessed only within your Virtual Private Cloud (VPC) network by using Private Service Connect. Employees and internal stakeholders who are within your network can use the server to securely transfer files to and from Cloud Storage.
You specify the projects that are allowed to connect to the server. You can optionally specify projects that are rejected from connecting.
For background information about VPC, see VPC overview.
For steps to create an external server, which can be accessed over the internet, see Create an external SFTP server. You can't change whether a server is external or internal after the server has been created.
Before you begin
gcloud
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
Create or select a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_IDwith a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_IDwith your Google Cloud project name.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud FTP API:
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.gcloud services enable ftp.googleapis.com
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
Create or select a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_IDwith a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_IDwith your Google Cloud project name.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud FTP API:
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.gcloud services enable ftp.googleapis.com
-
Collect the following information about your server's users:
- A list of project IDs or project numbers that are allowed to access the server.
- (Optional) A list of project IDs or project numbers that are rejected from accessing the server.
Required roles
To get the permission that
you need to create an SFTP server,
ask your administrator to grant you the
Cloud 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.servers.create
permission,
which is required to
create an SFTP server.
You might also be able to get this permission with custom roles or other predefined roles.
Create an internal server
gcloud
To create an internal server, run the
gcloud alpha storage ftp servers create command
and provide the --access-type=INTERNAL flag.
Before using any of the command data below, make the following replacements:
- SERVER_ID: a unique ID for the server. Must start with a lowercase letter, and end with a lowercase letter or number. Can contain lowercase letters, numbers, and hyphens. Maximum length is 30 characters.
-
LOCATION_ID: the Google Cloud location of the server, such as
us-west1.For the fastest data transfer speeds, create the server in the same location as the Cloud Storage bucket that stores your data. If the bucket's location isn't supported by Cloud FTP, then select the nearest available location.
-
PROJECT_TO_ALLOW: the project ID or number of a consumer project that is allowed to connect to the server by using Private Service Connect. For example,
example-allowed-project. You must specify at least one project.You can allow a maximum of 500 projects. Provide multiple projects and their respective connection limits in a comma-separated list. For example,
--consumer-accept-list=projectA=20,projectB=15. - CONNECTION_LIMIT: the maximum number of Private Service Connect endpoints that can be created in the consumer project. The value must be from 1 to 250 endpoints.
-
(Optional) PROJECT_TO_REJECT: the project ID or number of a consumer project that is prohibited from connecting to the server. For example,
example-rejected-project. Projects in this list are rejected from accessing the server even if they are included in the list of allowed projects.You can reject a maximum of 64 projects. Provide multiple projects in a comma-separated list.
If you don't want to explicitly reject any projects, then omit the--consumer-reject-listflag.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud alpha storage ftp servers create SERVER_ID --access-type=INTERNAL \ --location=LOCATION_ID \ --consumer-accept-list=PROJECT_TO_ALLOW=CONNECTION_LIMIT \ --consumer-reject-list=PROJECT_TO_REJECT
Windows (PowerShell)
gcloud alpha storage ftp servers create SERVER_ID --access-type=INTERNAL ` --location=LOCATION_ID ` --consumer-accept-list=PROJECT_TO_ALLOW=CONNECTION_LIMIT ` --consumer-reject-list=PROJECT_TO_REJECT
Windows (cmd.exe)
gcloud alpha storage ftp servers create SERVER_ID --access-type=INTERNAL ^ --location=LOCATION_ID ^ --consumer-accept-list=PROJECT_TO_ALLOW=CONNECTION_LIMIT ^ --consumer-reject-list=PROJECT_TO_REJECT
It takes about 10 minutes for the server to be created.
REST
To create an internal server, use the
servers.create method
and provide an internalConfig access configuration.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the Google Cloud project ID of the server.
-
LOCATION_ID: the Google Cloud location of the server, such as
us-west1.For the fastest data transfer speeds, create the server in the same location as the Cloud Storage bucket that stores your data. If the bucket's location isn't supported by Cloud FTP, then select the nearest available location.
- SERVER_ID: a unique ID for the server. Must start with a lowercase letter, and end with a lowercase letter or number. Can contain lowercase letters, numbers, and hyphens. Maximum length is 30 characters.
-
PROJECT_TO_ALLOW: the project ID or number of a consumer project that is allowed to connect to the server by using Private Service Connect. For example,
example-allowed-project. You must specify at least one project.You can allow a maximum of 500 projects.
- CONNECTION_LIMIT: the maximum number of Private Service Connect endpoints that can be created in the consumer project. The value must be from 1 to 250 endpoints.
-
(Optional) PROJECT_TO_REJECT: the project ID or number of a consumer project that is prohibited from connecting to the server. For example,
example-rejected-project. Projects in this list are rejected from accessing the server even if they are included in the list of allowed projects.You can reject a maximum of 64 projects.
If you don't want to explicitly reject any projects, then omit the
consumerRejectListobject.
HTTP method and URL:
POST https://ftp.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/servers?serverId=SERVER_ID
Request JSON body:
{
"accessType": "INTERNAL",
"internalConfig": {
"consumerAcceptList": [
{
"project": "projects/PROJECT_TO_ALLOW",
"connectionLimit": CONNECTION_LIMIT
}
],
"consumerRejectList": [
{
"project": "projects/PROJECT_TO_REJECT"
}
]
}
}
To send your request, expand one of these options:
The response identifies a long-running operation.It takes about 10 minutes for the server to be created.