macos 在 Amazon EC2 上上传文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10364950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uploading files on Amazon EC2
提问by Krish
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/
我有一个 Amazon EC2 实例正在运行。当我访问 url 时,我得到了 Apache 测试页面,它说我必须将我的文件上传到/var/html/
My question is, how do i do it? I use Mac OS X 's terminal for accessing the instance.
我的问题是,我该怎么做?我使用 Mac OS X 的终端来访问实例。
FTP doesn't seem to work. Is there any other way?
FTP 似乎不起作用。有没有其他办法?
回答by Serge Shultz
If you're using a Mac (or other *nix system), simply copy-paste this to terminal to upload a file via SSH
如果您使用的是 Mac(或其他 *nix 系统),只需将其复制粘贴到终端即可通过 SSH 上传文件
scp -i MyKeyFile.pem FileToUpload.pdf [email protected]:FileToUpload.pdf
replace "ec2-123-123-123-123.compute-1.amazonaws.com" with your instance's public DNS name
将“ec2-123-123-123-123.compute-1.amazonaws.com”替换为您实例的公共 DNS 名称
回答by Steffen Opel
You actually shouldn't use FTP to access Amazon EC2instances 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).
您实际上根本不应该使用 FTP 来访问Amazon EC2实例(或任何其他服务器,但这是一个不同的问题,请参阅稍微夸张但仍然适当的咆哮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.
相反,您应该使用SSH 文件传输协议 (SFTP),它通常在开箱即用的 EC2 实例上工作得很好,而无需在 SSH 访问之外进行额外的安全设置,即因为您已经可以通过 SSH 密钥进行访问也可以将这些用于 SFTP 与您最喜欢的 (S)FTP 客户端。
(S)FTP security
(S)FTP 安全
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!:
比无需额外安全/防火墙设置的开箱即用支持更重要的是 SFTP 是安全的,而 FTP 恰恰相反,请参见例如您的密码是什么?xyzzy?伟大的!:
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 clearfrom 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]
如前所述,FTP 早于 Internet 活动被认为是恶意的时代。因此,它没有针对密码嗅探、中间人攻击等的安全措施。
您的用户名和密码以明文形式从 FTP 客户端传输到 FTP 服务器。任何控制从客户端到服务器路径上的任何路由器的人都可以读取整个会话,包括您的密码。[强调我的]
Please note that this can be remedied to some extend by using FTP over SSLor FTP over SSH, but both requires additional work and provide no benefits over SFTP for regular use cases like yours.
请注意,这可以通过使用SSL 上的FTP或SSH 上的FTP来在一定程度上进行补救,但两者都需要额外的工作,并且对于像您这样的常规用例,SFTP 没有任何好处。
(S)FTP clients
(S)FTP 客户端
Nowadays most FTP clients should support SFTP as well one way or another, ideally facilitating an SSH authentication agentlike 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).
现在大多数 FTP 客户端都应该以一种或另一种方式支持 SFTP,理想情况下可以促进SSH 身份验证代理,如ssh-agent(Unix/Linux/Mac OS X) 或Pageant (Putty)(Windows) 以避免需要明确指定 SSH使用的关键(当然这也是可能的)。
There are likely plenty of SFTP clients for Mac OS X, a free one is Cyberduck, which is a LibreFTP, SFTP, WebDAV & cloud storage browser for Mac & Windows(see their SFTP Howto).
Mac OS X 可能有很多 SFTP 客户端,免费的一个是Cyberduck,它是适用于 Mac 和 Windows的LibreFTP、SFTP、WebDAV 和云存储浏览器(请参阅他们的SFTP Howto)。
回答by Αλ?κο?
The easiest way is to install webmin and user the file manager (java plugin) from your browser.
最简单的方法是从浏览器安装 webmin 并使用文件管理器(java 插件)。
//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
//修改root用户默认密码
passwd
Finally, open port 10000 in the security groups
最后在安全组中打开10000端口
Then, log into
然后,登录
https://server_name:10000
with user:root password:what_you_set_before
用户:root 密码:what_you_set_before
回答by NadZ
Sorry. none of the answer helped me..but i learnt from the answers. What helped me is that i was using the wrong security keyname.
对不起。没有一个答案对我有帮助……但我从答案中学到了。帮助我的是我使用了错误的安全密钥名。
Usesful Tips:
有用的提示:
- 1)if you have multiple security keys (.pem files), check your AWS account with Key pair name
- 2) Check the order of your SCP command parameters.
- 3) check if, “ubuntu” has the permission to write in the target directory.
- 1) 如果您有多个安全密钥(.pem 文件),请使用密钥对名称检查您的 AWS 账户
- 2)检查你的SCP命令参数的顺序。
- 3) 检查“ubuntu”是否有写入目标目录的权限。