Uploading files on Amazon EC2

2019-01-21 11:27发布

问题:

I have an Amazon EC2 instance running. When i access the url, I get the Apache Test page, and it says that i'll have to upload my files into /var/html/

My question is, how do i do it? I use Mac OS X 's terminal for accessing the instance.

FTP doesn't seem to work. Is there any other way?

回答1:

If you're using a Mac (or other *nix system), simply copy-paste this to terminal to upload a file via SSH

scp -i MyKeyFile.pem FileToUpload.pdf ubuntu@ec2-123-123-123-123.compute-1.amazonaws.com:FileToUpload.pdf

replace "ec2-123-123-123-123.compute-1.amazonaws.com" with your instance's public DNS name



回答2:

You actually shouldn't use FTP to access Amazon EC2 instances at all (or any other server for that matter, but that's a different issue, see the slightly exaggerated, but nonetheless appropriate rant FTP Must Die).

Rather, you should use the SSH File Transfer Protocol (SFTP), which usually works just fine on EC2 instances out of the box without requiring additional security settings outside of SSH access in place anyway, i.e. since you already have access via your SSH keys you can use these as well for SFTP with your favorite (S)FTP client.

(S)FTP security

Even more important than this out of the box support without additional security/firewall settings is that SFTP is secure, while FTP is exactly the opposite, see e.g. What's Your Password? xyzzy? Great!:

As stated earlier, FTP predates the age when Internet activity was expected to be malicious. As such, it has no provisions for security against password sniffing, man in the middle attacks, and so on.

Your username and password are transmitted in the clear from the FTP client to the FTP server. Anyone with control over any of the routers along the path from client to server can read the entire session, including your password. [emphasis mine]

Please note that this can be remedied to some extend by using FTP over SSL or FTP over SSH, but both requires additional work and provide no benefits over SFTP for regular use cases like yours.

(S)FTP clients

Nowadays most FTP clients should support SFTP as well one way or another, ideally facilitating an SSH authentication agent like ssh-agent (Unix/Linux/Mac OS X) or Pageant (Putty) (Windows) to avoid the need to explicitly specify the SSH key to use (though that's possible as well of course).

There are likely plenty of SFTP clients for Mac OS X, a free one is Cyberduck, which is a Libre FTP, SFTP, WebDAV & cloud storage browser for Mac & Windows (see their SFTP Howto).



回答3:

The easiest way is to install webmin and user the file manager (java plugin) from your browser.

//Go to home folder

cd ~

//Download the latest version

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.660-1.noarch.rpm

//install

sudo rpm -U webmin-1.660-1.noarch.rpm

//Change default password of root user

passwd

Finally, open port 10000 in the security groups

Then, log into

https://server_name:10000 

with user:root password:what_you_set_before