25

I use SSH to connect to my Ubuntu instance. With SSH I can administer files and folders on the instance, but how do I upload files and folders from my local machine to the instance?

Is it possible to do right from SSH session, without using SFTP clients?

8 Answers 8

10

Just to add a bit more detail to the scp command (included in OSx and most linux/unix):

scp -i myssh.pem local_file username@200.200.200.200:/home/username

Obviously - replace the pem file with the one used for ssh access. Obviously replace "username" and "200.200.200.." with valid values for your setup.

1
  • With regards to the local file, I get: No such file or directory
    – O0123
    Jan 21, 2021 at 10:03
10

You can try kitten utility which is a wrapper around boto3. You can easily upload/download files and run commands on EC2 server or on multiple servers at once for that matter.

kitten put -i ~/.ssh/key.pem cat.jpg /tmp [SERVER NAME][SERVER IP]

Where server name is e.g ubuntu or ec2-user etc.

This will upload cat.jpg file to /tmp directory of server

9

As mentioned already, I've used WinSCP, which logs me in as "ec2-user" - then make sure to adjust that user's permissions via SSH. Example:

chown -R ec2-user /path/to/files

(Authenticate as the root user first.)

Whatever folder or files you need to edit via WinSCP, allow permissions on them (otherwise you will get a permission denied error when trying to upload/edit files in WinSCP).

1
  • 1
    This worked. But as a noob I can't tell if there are any security issues that would be associated with this solution. Any thoughts from the community? Aug 24, 2013 at 10:09
5

you cannot copy files using ssh. you can use scp/sftp.

scp if you are on linux or winscp if you are on windows

3
  • 4
    I found out Filezilla to be way faster than WinSCP for uploading files to my EC2 instances, if that might help.
    – Viccari
    Jun 5, 2012 at 1:57
  • @Viccari could you mention the steps to use filezilla with ec2 Jul 9, 2014 at 11:18
  • 1
    @HarpreetBhatia should be straightforward. You need to add your keypair to FileZilla, configure your username/password and hostname. That should do it.
    – Viccari
    Jul 9, 2014 at 21:58
5

You can use this:

scp -i yourkeypair.pem source destination
1

This Works Fine

scp -r -i myssh.pem /local/directory remote_username@10.10.0.2:/remote/directory

-r for recursive

0

You could also install and set up an FTP Server, which will allow you to set up users, and directories for them to upload to. That being said, I've upvoted the above because scp/sftp is the ideal method.

0

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.