How to give access to the Client on SFTP server for s3 bucket accessing using key pair on AWS?

853 Views Asked by At

We want give access to the client for accessing s3 bucket on AWS by using AWS SFTP server based on the public key authentication, how to give access to the client based on public key authentication, what are the steps we will follow for the same ?

2

There are 2 best solutions below

0
On

If you are using AWS Transfer for SFTP, then you should:

  • Ask the user to generate an RSA keypair and provide you with the public key
  • Create a user in the AWS Transfer server and attach the public key

The user should then be able to connect to the server by using their private key.

I think you'll also need to create an IAM Role that grants the user access to the appropriate S3 bucket. See: Working with service-managed users - AWS Transfer Family

0
On

I created the key pair using ssh-keygen, then these two keys are store in same folder. following script is passed then file is automatically transferred to cliet folder

echo " Privatekey,PublicKey (copied)"
               
           chmod 600 $folder/id_rsa
# private key permission changed    
           filechmod_result=`echo $?`
        if [[ $filechmod_result -eq  0 ]];
                then
                     echo "chmod is success 12345678"
                else
                 echo "chmod is fail"
                 fi 
             
 sftp -o Port=8022 -o IdentityFile=$folder/id_rsa -o StrictHostKeyChecking=no $username@$servername << !
            cd client folder
            put $folder/$client folder
            ls