{"id":2086,"date":"2020-11-20T17:53:37","date_gmt":"2020-11-20T14:53:37","guid":{"rendered":"https:\/\/artem.services\/?p=2074"},"modified":"2020-11-20T21:29:58","modified_gmt":"2020-11-20T18:29:58","slug":"2086","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=2086&lang=en","title":{"rendered":"AWS Transfer &#8212; Public FTP"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-214\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png\" alt=\"\" width=\"975\" height=\"450\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png 975w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-300x138.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-768x354.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-954x440.png 954w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/p>\n<p><strong>AWS Transfer<\/strong> supports 3 protocols: <strong>SFTP<\/strong>, <strong>FTP<\/strong>, and <strong>FTPS<\/strong>. And only <strong>SFTP<\/strong> can have a public endpoint, <strong>FTP<\/strong>\/<strong>FTPS<\/strong> can only be run inside a <strong>VPC<\/strong>. Also for <strong>login<\/strong>\/<strong>password<\/strong> authorization, you must use a custom provider, you can find more information about this <a href=\"https:\/\/docs.aws.amazon.com\/transfer\/latest\/userguide\/authenticating-users.html\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<h3>Goal:<\/h3>\n<p>Create an <strong>AWS Transfer<\/strong> server for the <strong>FTP<\/strong> protocol, the service must be public and authorization must also be by login \/ password.<\/p>\n<blockquote><p><strong>FTP<\/strong> is insecure and <strong>AWS<\/strong> does not recommend using it on public networks.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>The first thing you need is the <a href=\"https:\/\/docs.aws.amazon.com\/serverless-application-model\/latest\/developerguide\/serverless-sam-cli-install.html\" target=\"_blank\" rel=\"noopener noreferrer\">AWS SAM CLI<\/a> installed.<\/p>\n<p>Create a directory where we will download the template, go to it and download:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nwget https:\/\/s3.amazonaws.com\/aws-transfer-resources\/custom-idp-templates\/aws-transfer-custom-idp-secrets-manager-sourceip-protocol-support-apig.zip\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Unzip and run the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsam deploy --guided --stack-name aws-transfer-ftp\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p>Where, &quot;<strong>aws-transfer-ftp&quot;<\/strong> is the name of the created <strong>CloudFormation<\/strong> stack, if you specify the name of an existing one, it will update it.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>Then the interactive installation will start, where you will be prompted to specify the following parameters:<\/p>\n<ul>\n<li><strong>Stack Name<\/strong> &#8212; the name of the <strong>CloudFormation<\/strong> stack, the default is the value of the &quot;<strong>&#8212;stack-name<\/strong>&quot; key parameter;<\/li>\n<li><strong>AWS Region<\/strong> &#8212; the region where the <strong>CloudFormation<\/strong> stack will be deployed;<\/li>\n<li><strong>Parameter CreateServer<\/strong> &#8212; whether <strong>AWS Transfer<\/strong> service will be created (by default &#8212; <strong>true<\/strong>);<\/li>\n<li><strong>Parameter SecretManagerRegion<\/strong> &#8212; if your region does not support <strong>SecretsManager<\/strong>, then you can specify a separate region for it;<\/li>\n<li><strong>Parameter TransferEndpointType<\/strong> &#8212;\u00a0<strong>PUBLIC<\/strong> or <strong>VPC<\/strong>, since <strong>FTP<\/strong> does not support public endpoints, specify <strong>VPC<\/strong>;<\/li>\n<li><strong>Parameter TransferSubnetIDs<\/strong> &#8212;\u00a0<strong>ID<\/strong>&#39;s of the subnets in which the <strong>AWS Transfer<\/strong> endpoint will be;<\/li>\n<li><strong>Parameter TransferVPCID<\/strong> &#8212;\u00a0<strong>VPC ID<\/strong> where the subnets specified in the previous parameter are located.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2075\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.34.34.png\" alt=\"\" width=\"1466\" height=\"744\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.34.34.png 1466w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.34.34-300x152.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.34.34-1024x520.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.34.34-768x390.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.34.34-954x484.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.34.34-1354x687.png 1354w\" sizes=\"(max-width: 1466px) 100vw, 1466px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s create a <strong>SecurityGroup<\/strong> for the <strong>FTP<\/strong> service in the required <strong>VPC<\/strong>. And we will allow incoming traffic to <strong>TCP<\/strong> ports <strong>21<\/strong> and <strong>8192<\/strong>&#8212;<strong>8200<\/strong> from any address. While we save the created <strong>SG<\/strong>, we will attach it in the future.<\/p>\n<p>Then go to the <strong>AWS<\/strong> Console &#8212; &quot;<strong>AWS Transfer Family<\/strong>&quot;, find the server created by <strong>AWS Transfer<\/strong> and edit its protocol, uncheck the &quot;<strong>SFTP<\/strong>&quot; protocol and select &quot;<strong>FTP<\/strong>&quot; protocol, and save the changes.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2079\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48.png\" alt=\"\" width=\"1598\" height=\"388\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48.png 1598w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48-300x73.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48-1024x249.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48-768x186.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48-1536x373.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48-954x232.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.03.48-1354x329.png 1354w\" sizes=\"(max-width: 1598px) 100vw, 1598px\" \/><\/p>\n<p>Now we need to add access to <strong>FTP<\/strong> from the world, for this we will use <strong>NLB<\/strong>. First, let&#8217;s find out the private <strong>IP<\/strong> addresses of <strong>VPC<\/strong> endpoint for <strong>AWS Transfer<\/strong>, for this in the &quot;<strong>Endpoint details<\/strong>&quot; block, click on the link to the <strong>VPC<\/strong> endpoint.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2080\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00.png\" alt=\"\" width=\"2100\" height=\"686\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00.png 2100w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00-300x98.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00-1024x335.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00-768x251.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00-1536x502.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00-2048x669.png 2048w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00-954x312.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.05.00-1354x442.png 1354w\" sizes=\"(max-width: 2100px) 100vw, 2100px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Go to the &quot;<strong>Subnets<\/strong>&quot; tab and copy all the <strong>IP<\/strong> addresses, they will be needed to create target groups.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2081\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.10.41.png\" alt=\"\" width=\"1262\" height=\"484\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.10.41.png 1262w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.10.41-300x115.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.10.41-1024x393.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.10.41-768x295.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.10.41-954x366.png 954w\" sizes=\"(max-width: 1262px) 100vw, 1262px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Go to the &quot;<strong>Security Groups<\/strong>&quot; tab and change the default security group to the one created earlier.<\/p>\n<p>Now let&#8217;s create a target group, for this in the AWS console go to &quot;<strong>EC2<\/strong>&quot; -&gt; &quot;<strong>Load Balancing<\/strong>&quot; -&gt; &quot;<strong>Target Groups<\/strong>&quot; and create the first target group for <strong>TCP<\/strong> port <strong>21<\/strong>.<\/p>\n<ul>\n<li><strong>Target type<\/strong>: IP address<\/li>\n<li><strong>Protocol<\/strong>: TCP<\/li>\n<li><strong>Port<\/strong>: 21<\/li>\n<\/ul>\n<blockquote><p>It is better to indicate the port number in the name of the target group at the end, since there will be 10 of them and you can easily get confused.<\/p><\/blockquote>\n<p>We will also indicate the <strong>VPC<\/strong> in which the <strong>AWS Transfer<\/strong> service was created. In the next tab, one by one, we will indicate the <strong>IP<\/strong> addresses of the <strong>VPC<\/strong> endpoint, which we looked at earlier. We save the target group.<\/p>\n<p>Now you need to create 9 more target groups for the port range: <strong>TCP<\/strong> <strong>8192<\/strong>&#8212;<strong>8200<\/strong>. The procedure is the same as for the target group for port <strong>21<\/strong>, except that you need to specify port <strong>21<\/strong> for <strong>HeathCheck<\/strong>. To do this, in the &quot;<strong>Health checks<\/strong>&quot; block, open the &quot;<strong>Advanced health check setting<\/strong>&quot; tab, select &quot;<strong>Overrive<\/strong>&quot; and specify the port number &#8212; <strong>21<\/strong>.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2082\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10.png\" alt=\"\" width=\"1666\" height=\"776\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10.png 1666w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10-300x140.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10-1024x477.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10-768x358.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10-1536x715.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10-954x444.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-19.34.10-1354x631.png 1354w\" sizes=\"(max-width: 1666px) 100vw, 1666px\" \/><\/p>\n<p>After we are done with target groups, we need to create an &quot;<strong>internet-facing<\/strong>&quot; <strong>Network Load Balancer<\/strong> and place it on public networks of the same <strong>VPC<\/strong> where the <strong>AWS Transfer<\/strong> service is. We also create <strong>10<\/strong> listeners, for <strong>TCP<\/strong> ports <strong>21<\/strong>, and for the range <strong>8192<\/strong>&#8212;<strong>8200<\/strong>, and for each listener we point the desired target group corresponding to the port number. After which the FTP service must be accessible from outside.<\/p>\n<p>In order to add an <strong>FTP<\/strong> user, go to the &quot;<strong>Secrets Manager<\/strong>&quot; in the <strong>AWS<\/strong> console and create a secret with the &quot;<strong>Other type of secrets<\/strong>&quot; type.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2083\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35.png\" alt=\"\" width=\"1548\" height=\"618\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35.png 1548w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35-300x120.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35-1024x409.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35-768x307.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35-1536x613.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35-954x381.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-20-at-12.13.35-1354x541.png 1354w\" sizes=\"(max-width: 1548px) 100vw, 1548px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Create 3 &quot;<strong>key\/value<\/strong>&quot; pairs:<\/p>\n<ul>\n<li><strong>Password<\/strong> &#8212; password for the new <strong>FTP<\/strong> user;<\/li>\n<li><strong>Role<\/strong> &#8212;\u00a0<strong>ARN<\/strong> of the role that has write permission to the required <strong>S3<\/strong> bucket;<\/li>\n<li><strong>HomeDirectoryDetails<\/strong> &#8212; [{&quot;Entry&quot;: &quot;\/&quot;, &quot;Target&quot;: &quot;\/s3-bucket\/user-name&quot;}]<\/li>\n<\/ul>\n<blockquote><p>Where &quot;<strong>s3-bucket<\/strong>&quot; is the name of the <strong>S3<\/strong> bucket, &quot;<strong>user-name<\/strong>&quot; is the name of the directory that the user will go to when connecting to the <strong>FTP<\/strong> server (the directory name does not have to match the username, and may also be located outside the root of the bucket)<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>We must save the secret with a name in the format: &quot;<strong>server_id\/user_name<\/strong>&quot;, where &quot;<strong>server_id<\/strong>&quot; is the <strong>AWS Transfer<\/strong> server <strong>ID<\/strong>, &quot;<strong>user_name<\/strong>&quot; is the username that will be used to connect to the <strong>FTP<\/strong> server.<\/p>\n<p>For convenience, you can also create a <strong>DNS CNAME<\/strong> record for the <strong>NLB<\/strong> record.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS Transfer supports 3 protocols: SFTP, FTP, and FTPS. And only SFTP can have a public endpoint, FTP\/FTPS can only be run inside a VPC. Also for login\/password authorization, you must use a custom provider, you can find more information about this here. Goal: Create an AWS Transfer server for the FTP protocol, the service &hellip; <a href=\"https:\/\/artem.services\/?p=2086&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;AWS Transfer &#8212; Public FTP&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[599],"tags":[543,1723,1725,1727,1729,1731],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2086"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2086"}],"version-history":[{"count":3,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2086\/revisions"}],"predecessor-version":[{"id":2091,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2086\/revisions\/2091"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}