第一步:

在客户端机器先创建ssh key,登陆机器,然后输入命令:ssh-keygen

找到public key,稍后添加用户时需要。

第二步:

进入AWS Console,IAM,创建Role

AWS Transfer Family创建新用户_创建

具体json如下:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "transfer.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }

然后点Next,Add Permission 先忽略,继续Next

AWS Transfer Family创建新用户_创建_02

给个Role name,然后creat role

AWS Transfer Family创建新用户_用户_03

回到Role,点选刚创建的Role,Add permisisons --> Create inline policy

AWS Transfer Family创建新用户_transfer family_04

具体json如下:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:ListBucketVersions" ], "Resource": "arn:aws:s3:::your-s3-bucket-name", "Condition": { "StringLike": { "s3:prefix": "your-folder-in-bucket/*" } } }, { "Effect": "Allow", "Action": "s3:星*号", "Resource": "arn:aws:s3:::your-s3-bucket-name/your-folder-in-bucket/*", "Condition": {} } ] }

给polcy一个名字,然后create policy

AWS Transfer Family创建新用户_用户_05

第三步,创建IAM policy

AWS Transfer Family创建新用户_用户_06

给个名字,然后create policy

AWS Transfer Family创建新用户_transfer family_07

第四步:去Transfer Family界面,点server,然后找到Add user

AWS Transfer Family创建新用户_用户_08

按要求填好信息

AWS Transfer Family创建新用户_用户_09

如果报错Permission denied,则检查如下2点

1, Restricted 要打勾

AWS Transfer Family创建新用户_用户_10

2, 检查IAM Policy里S3路径是否正确

AWS Transfer Family创建新用户_transfer family_11

关于添加public key,用puttygen生成的key默认是这样的

AWS Transfer Family创建新用户_用户_12

添加时需要修改成如下这样,前面加ssh-rsa 空格,全部放一行,不能换行,否则会报格式错误。

AWS Transfer Family创建新用户_创建_13


2024-4-11 遇到一种情况是S3 bucket是通过KMS用户自定义key加密的情况,Role policy需要添加KMS访问

{

    "Version": "2012-10-17",

    "Statement": [

        {

            "Sid": "DownloadandUpload",

            "Action": [

                "s3:*"

            ],

            "Effect": "Allow",

            "Resource": "arn:aws:s3:::s3-bucket-name/*”

        },

        {

            "Sid": "ListBucket",

            "Action": [

                "s3:ListBucket"

            ],

            "Effect": "Allow",

            "Resource": "arn:aws:s3:::s3-bucket-name"

        },

        {

            "Sid": "KMSAccess",

            "Action": [

                "kms:Decrypt",

                "kms:GenerateDataKey"

            ],

            "Effect": "Allow",

            "Resource": "arn:aws:kms:kms-key-arn”

        }

    ]

}

AWS Transfer Family创建新用户_用户_14