An often overlooked, but important task is to sync files on Mac. There are a…
Find out how to connect to your Linux instance of EC2 with SFTP with your Mac. Browse, upload and download files easily after following this guide.
Amazon offers virtual server capabilities with their Elastic Compute Cloud (EC2), part of the Amazon Web Services (AWS) infrastructure. It allows you to easily increase or decrease capacity while still maintaining control over your compute instances.
But you probably already know all this and you just want to connect to your EC2 with SFTP to download or upload files.
Setup SSH Keys
First you’ll need to setup the SSH keys. Open AWS Console EC2 page and in the sidebar choose Network & Security > Key Pairs.
Here choose Create Key Pair in the top-right corner.
Type a name for your key pair and make sure .pem is selected. Click Create Key
Allow the file download and save it on your Mac.
Create EC2 instance
Skip to the next section if you already have a Linux EC2 instance running.
If you haven’t created at least one EC2 instance, you’ll need to set one up at this point. Follow the official guide from Amazon and setup a Linux instance. The exact distribution is up to your preference. For beginners we recommend using Ubuntu.
On the EC2 page, choose Instances, then click on the instance you want to connect to.
In the Details panel you’ll see the Public IPv4 address. Copy this address.
Next make sure you have the SSH port accessible. Click on the Security tab for the instance and look at inbound rules. By default, the SSH port is 22. If you’ve configured sshd to use a different port, make sure it’s open and in the inbound ruleset.
Connecting to Amazon EC2 with SFTP using DCommander
Now that you’ve setup your cloud compute instance to accept SSH connections, you’re very close to downloading and uploading files to it.
To make file management an easy task we use DCommander. With it’s dual-panel interface you always have a clear image of what files are local and what files are on the remote EC2 server.
Get DCommander now if you haven’t installed it already.
Open DCommander, click on the Connection Manager.
In the Connection Manager, click on Add New Connection.
You’ll now be prompted to enter connection details.
Select type as SFTP (SSH) and type the Public IPv4 address you saved previously followed by : and port number (default SSH port is 22).
Depending on what Linux distribution you chose for your EC2 instance, you’ll need to type the default username:
- For Amazon Linux 2 or the Amazon Linux AMI, the user name is
- For a CentOS AMI, the user name is
- For a Debian AMI, the user name is
- For a Fedora AMI, the user name is
- For a RHEL AMI, the user name is
- For a SUSE AMI, the user name is
- For an Ubuntu AMI, the user name is
- For an Oracle AMI, the user name is
- For a Bitnami AMI, the user name is
See the Amazon EC2 documentation page for Managing User Accounts on Linux for more information.
For authentication choose Public Key Authentication then click Browse and select the .pem file you downloaded previously.
Click OK after entering all the details to save your connection.
Select the newly created connection and click Connect.
DCommander will now connect to your instance of Linux EC2 with SFTP and allow you to navigate, copy, delete and create new files and folders.
DCommander will automatically reconnect in case the network connection drops, allowing you to continue without manually reconnecting each time.
That’s it – you can now manage files on EC2 with SFTP using your Mac.