Cant Upload to Aws Ec2 With Root
Uploading and downloading files in AWS example tin can be done using Filezilla customer or Linux scp command. If you are a windows user, you can utilize WinSCP for transferring files to your EC2 instance.
In this tutorial, I volition explicate how you can transfer files to AWS ec2 instances using the following methods.
- Copy Files Using Filezilla Customer (GUI Based).
- Re-create files using SCP (Works only on Linux/MAC systems)
Upload Files To EC2 using FileZilla
To transfer files to ec2 Linux instance, we will employ FileZilla
Y'all tin download the FileZilla client from hither Download FileZilla.
Step1: Install and open up FileZilla
Step2: Go To Edit–>Settings–>SFTP
Note: By default, AWS ec2 instances come with a private key for login. We volition utilize that private cardinal with Filezilla. If you want to setup a password-based access, check out the ec2 password setup blog.
Click add cardinal file and add together your .ppk key of your AWS example and and so click ok. You tin can convert the AWS pem file to ppk using puttygen. Refer to this tutorial –> How To Create .ppk File Using PuttyGen
Step3: In the FileZilla homepage enter the host details (public IP, elastic IP or the public DNS) and enter the username in the relevant field. ( username varies for unlike images.
For ubuntu Instance, the username will be ubuntu, for Linux machines, the username volition be ec2-user) .
Leave the password field empty, since nosotros are using the individual key for authentication.
Port number is 22 for SFTP. One time y'all enter all the necessary details click connect.
Filezilla will be continued to your server instance and you can view your server files and folders.
Step4: File Upload And Download:- Once FileZilla is connected to your server instance, yous can upload files to your instance, and also you tin can download files from your server instance.
The local site is your local system files. The remote site is your server example.
To upload files choose the directory on your server where yous want your files to exist uploaded.
Now select the file to be uploaded and right-click on it. Click the upload file option. Your file starts uploading to the directory yous selected. Similarly, you can download files from your server instance by right-clicking the file.
Few important things to understand,
- Since you are logging in as a user, y'all cannot upload the files to the root directory due to permissions bug. Alternatively, upload the files to the user abode directory and copy information technology to the desired location using whatever ssh client similar putty.
- You will be uploading and downloading files as a normal user and non a root user. So the files which are owned by root cannot be uploaded and downloaded. You will go permission denied mistake when you try to download a file owned past root.
So, if you lot want to download those files, ssh into the automobile and change the owner of that file to the normal user using the post-obit command.
sudo chown user:user /folder/file
In the above command, the user is your case's default username. For example, for ubuntu instances, it'south ubuntu and for RHEL instances its ec2-user. Give the username accordingly. If y'all desire to change the owner of a recursive folder, add a -R switch to the command, as shown below.
sudo chown -R user:user /binder/file
Upload File Using SCP Command Line Utility
If you are using a Linux or Mac system, you can use the scp utility to upload or transfer files to ec2 instance.
Notation: Ensure that your pem file has only read permission to it. Or else the connection might fail.
Let's have a expect at the syntax.
scp -i /path/to/key.pem file-name [e-mail protected]:/path/to/user/home
For example,
scp -i /keys/mykey.pem file.txt [email protected]:/home/ubuntu
If you want to copy a whole binder, then yous should use a recursive flag -r with the command as shown below.
scp -i /keys/mykey.pem -r folder-name [electronic mail protected]:/dwelling house/ubuntu
I promise this commodity helps. Let me know in the comments section if you lot face up any errors.
If you want to copy files from Windows to Linux, check out my windows to Linux file copy guide.
Conclusion
Transferring files to ec2 servers is very essential when you lot host applications like wordpress in ec2.
Always make sure yous follow good security practices and provide only required permission to the files in the server.
Also, always enable correct security group rules to enable an actress layer of the firewall to reduce the assail surface of your websites.
Source: https://comtechies.com/how-to-upload-and-download-files-in-amazon-aws-ec2-instance.html
Post a Comment for "Cant Upload to Aws Ec2 With Root"