ChatGPT解决这个技术问题 Extra ChatGPT

Connect to Amazon EC2 file directory using Filezilla and SFTP

I have created an AWS EC2 Instance and I want to be able to upload files to the server directory using FileZilla in the simplest and most straightforward fashion possible.

So what is the question? If you have SSH/SFTP credentials, simply use FileZilla and connect to the site? Open the Site Manager, add your site (select SFTP as protocol) and store it. Make Site Manager open up each time you open FileZilla, so you just have to double-click on the Site Manager item.
Any specified problem you are having with your task?

p
petezurich

I've created a video tutorial for this. Just check:

Connect to Amazon EC2 file directory using FileZilla and SFTP, Video Tutorial

Summary of above video tutorial:

Edit (Preferences) > Settings > Connection > SFTP, Click "Add key file” Browse to the location of your .pem file and select it. A message box will appear asking your permission to convert the file into ppk format. Click Yes, then give the file a name and store it somewhere. If the new file is shown in the list of Keyfiles, then continue to the next step. If not, then click "Add keyfile..." and select the converted file. File > Site Manager Add a new site with the following parameters: Host: Your public DNS name of your EC2 instance, or the public IP address of the server. Protocol: SFTP Logon Type: Normal User: From the docs: "For Amazon Linux, the default user name is ec2-user. For RHEL5, the user name is often root but might be ec2-user. For Ubuntu, the user name is ubuntu. For SUSE Linux, the user name is root. For Debian, the user name is admin. Otherwise, check with your AMI provider." Press Connect Button - If saving of passwords has been disabled, you will be prompted that the logon type will be changed to 'Ask for password'. Say 'OK' and when connecting, at the password prompt push 'OK' without entering a password to proceed past the dialog. Note: FileZilla automatically figures out which key to use. You do not need to specify the key after importing it as described above.

If you use Cyberduck follow this.

Check this post if you have any permission issues.


for free tier ubuntu distributions username will be ubuntu.
To add to what was mentioned above make sure you delete the default value of 21 in port text box (default for sftp) as it seems to work with port 22. It started working for me when I deleted the port.
Saved me there @streak
@Yasitha Chinthaka I have followed all steps but cannot connect to my instance. It is a large instance on Windows server 2012. Any help appreciated. I have added the inbound rule for SSH on my security group. Is there any other configuration needed or changes since you last posted this answer?
Cannot connect as in, what kind of error message you get? I haven't tried this with Windows server though, but should be the same procedure.. make sure your username is correct...
E
Elshan

This is very simple if you used your pem file ( I am using macOS / windows users can follow the same steps.)

Just download your FileZilla (I'm using macOS - and downloaded the free version, that's good enough) Open Site Manager in FileZilla (⌘S) -> New Site

https://i.stack.imgur.com/lovBg.png

Put your hostname in the Host field.

Example: eca-**-**-**-111.ap-southwest-9.compute.amazonaws.com

Select Protocol as SFTP - SSH File Transfer Protocol

Select Logon type as Key File

Put your user name in the User field : for me it's ubuntu (find your ssh user)

Note:

OS vs Username Amazon - ec2-user Centos - centos Debian - admin or root Fedora - ec2-user RHEL - ec2-user or root SUSE - ec2-user or root Ubuntu - ubuntu or root

For the Key file field, browse your pem file: and click Connect

https://i.stack.imgur.com/PbfPO.png

That's all :) have fun!

Note:

(Remember to allow SSH connection to your IP address from EC2) If not you will get connecting error message!

Note: Allowing your IP to connect your AWS instance via SFTP

EC2 -> SecurityGroups -> SSH -> Inbound rules -> Edit -> Add Rule ( SSH|TCP|22|My IP(it's get ip automatically | name for rule) -> Save


does filezilla encrypt the aws keys on disk or store in plain text?
I reckon key file is already encrypted, therefore it just pass the file as it is. not encrypted. But if you are using normal authentication using username and password with Filezilla then they encrypt the password.
This is great, but wanted to add a note: instead of using the public hostname, I used the IPv4 IP address, for the Host input. That's when it worked for me.
For linux 2 the user is ec2-user
For AWS using the WordPress Bitnami image the user name was ubuntu for me
J
Jerad

If anyone is following all the steps and having no success, make sure that you are using the correct user. I was attempting to use "ec2-user" but I needed to use "ubuntu."


I was having no success on RedHat and the user name is "ec2-user".
For WordPress users with the most used WordPress Certified by Bitnami installation, it is on a Ubuntu server and therefore the username ubuntu :)
T
TJ Tang

Make sure you use port 22. Filezilla will default to port 21 for SFTP.


L
Lucio Mollinedo

Just one minor note to the well explained accepted answer of Yasitha Chinthaka:

Note: FileZilla automatically figures out which key to use. You do not need to specify the key after importing it as described above.

In my case I already had other 5 ppks from other instances that I was using in the past (with the ppk of the new instance being at the bottom of that list). I added the new ppk of my new instance, and it wouldn't let me connect to it. The error message: too many tries / attempts.

After I deleted the unused ppks, I was finally able to login to the instance.

So no, Filezilla is not that smart ;-)


This solved a problem that I had. Thanks for posting it!
K
Kilian Batzner

FileZilla did not work for me, I kept getting this error:

Disconnected: No supported authentication methods available (server sent: publickey)

What did work was the sftp command.

Connect with the EC2 Instance with

sftp -i "path/to/key.pem" ec2-user@ec2-54-212-34-84.us-west-2.compute.amazonaws.com

Downloading files / dirs

To download path/to/source/file.txt and path/to/source/dir:

lcd ~/Desktop
cd path/to/source
get file.txt
get -r dir

Uploading files / dirs

To upload localpath/to/source/file.txt and ~/localpath/to/source/dir to remotepath/to/dest:

lcd localpath/to/source
cd remotepath/to/dest
put file.txt
put -r dir

Filezilla also have sftp
Same issue with filezilla 3.7. The sftp command-line tool worked for me, too.
Kilian's methods worked for me. The FileZilla method returns the error: FATAL ERROR: No supported authentication methods available (server sent: publickey)
D
Deepak Singhal

You can use any FTP client. I use winscp and it works just fine. In all these clients; you can specify the ssh secure key.


x
xelber

Old question but what I've found is that, all you need is to add the ppk file. Settings -> Connections -> SFTP -> Add keyfile User name and the host is same as what you would provide when using putty which is mentioned in http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-connect-to-instance-linux.html Might help someone.


s
site80443

In my case, Filezilla sends the AWS ppk file to every other FTP server I try to securely connect to.

That's crazy. There's a workaround as written below but it's ugly.

It does not behave well as @Lucio M pointed out.

From this discussion: https://forum.filezilla-project.org/viewtopic.php?t=30605

n0lqu:

Agreed. However, given I can't control the operation of the server, is there any way to specify within FileZilla that a site should authenticate with a password rather than key, or vice-versa? Or tell it to try password first, then key only if password fails? It appears to me it's trying key first, and then not getting a chance to try password.

botg(Filezilla admin) replied:

There's no such option.

n0lqu:

Could such an option be added, or are there any good workarounds anyone can recommend? Right now, the only workaround I know is to delete the key from general preferences, add it back only when connecting to the specific site that requires it, then deleting it again when done so it doesn't mess up other sites.

botg:

Right now you could have two FileZilla instances with separate config dirs (e. g. one installed and one portable).

timboskratch:

I just had this same issue today and managed to resolve it by changing the "logon type" of the connection using a password in the site manager. Instead of "Normal" I could select either "Interactive" or "Ask for Password" (not really sure what the difference is) and then when I tried to connect to the site again it gave me a prompt to enter my password and then connected successfully. It's not ideal as it means you have to remember and re-type you password every time you connect, but better than having to install 2 instances of FileZilla. I totally agree that it would be very useful in the Site Manager to have full options of how you would like FileZilla to connect to each site which is set up (whether to use a password, key, etc.) Hope this is helpful! Tim

Also see: https://forum.filezilla-project.org/viewtopic.php?t=34676

So, it seems:

For multiple FTP sites with keys / passwords, use multiple Filezilla installs, OR, use the same ppk key for all servers.

I wish there was a way to tell FileZilla which ppk is for which site in Site Manger


C
Community

the most simple and straight forward is to create a FTP login. Here is a little and easy to understand tutorial site on stackoverflow itself, how to set things up in 2min... Setting up FTP on Amazon Cloud Server


I crosslinked to an url on stackoverflow. I do not consider this an external link, do you?
P
Patrick R

First of all Filezilla is an FTP/SFTP client/server. We will need to use the client for this purpose.

1) Download the client from the URL: https://filezilla-project.org/

2) Go to AWS management console and then EC2. Select the instance that you want to access and then copy the DNS or IP address of the instance and then paste it in Filezilla host name.

Follow Image: Amazon Instance Access via FileZilla

3) Then, enter the username for the instance that you have created, For Amazon-ami it will be ec2-user and for other OS it would be different. Then, enter the password and port which will be 21 or 22.

4) Then, it will ask for the key, which is in pem format just select the .pem file and then it will confirm authentication. Click on Yes and then you are Done.

Note: In your EC2 Security group allow port number 21 and 22 whichever required for FTP access.


E
Ebuzer Taha KANAT

all you have to do is: 1. open site manager on filezilla 2. add new site 3. give host address and port if port is not default port 4. communnication type: SFTP 5. session type key file 6. put username 7. choose key file directory but beware on windows file explorer looks for ppk file as default choose all files on dropdown then choose your pem file and you are good to go.

since you add new site and configured next time when you want to connect just choose your saved site and connect. That is it.


Ebuzer, this results in the error: "FATAL ERROR: No supported authentication methods available (server sent: publickey)" That's a variation on Kilian's message.
P
Pat

If you are comfortable using command lines, and use git bash to ssh to remote server (ubuntu, etc) from your PC, you may use sftp as below, works great always, and seems very fast. The pem file can be downloaded from aws EC2 or Lightsail, or any server. In the below command replace the path/namd of the pem file. Also replace the IP address to that of remote server [say remote Unix or linux/ubuntu server.]

$ sftp -i /c/Users/pat/Downloads/LightsailDefaultKey-us-east-1-2.pem ubuntu@123.45.6789

Additional commands for actual upload/download using sftp Go to remote folder sftp> pwd sftp> cd /home/ubuntu/mymedia

Go to local folder sftp> lpwd Local working directory: / sftp> lcd /c/Users/pat/Desktop/Camtasia To upload local files to server sftp> put * Or use get if you need to download to your local PC sftp> get *

Note: this is similar to the ssh to connect to remote using pem file. $ ssh -i /c/Users/pat/Downloads/LightsailDefaultKey-us-east-1-2.pem ubuntu@123.45.6789

Thanks!


A
Aidos

For Ubuntu users, there is another way of making and setting up a key without PuttyGen. I assume that you can connect to the server via terminal and want to set up FileZilla for file transferring.

In terminal execute the command:

ssh-keygen

It will prompt you to enter the destination path for the private and public keys files, by default it's

/home/user/.ssh/id_rsa and /home/user/.ssh/id_rsa.pub

you can leave it as is. Then, open the public key and copy its content:

cat .ssh/id_rsa.pub

In the terminal, on the server-side, open the .ssh/authorized_keys and paste the copied line there:

nano .ssh/authorized_keys

You will probably see there some present lines like "ssh-rsa AAAAB3Nz...". It's okay. Simply put the new line and paste the line copied before.


R
Rohit Sharma

https://www.cloudjojo.com/how-to-connect-ec2-machine-with-ftp/

First you have to install some ftp server on your ec2 machine like vsftpd. Configure vsftpd config file to allow writes and open ports. Create user for ftp client. Connect with ftp client like filezilla.

Make sure you open port 21 on aws security group.