Can't change permissions to upload to EC2 - amazon-web-services

I read over two hours for solutions but now post my question.
I only need to update one single file on an AWS EC2 (centos server) and always have used FileZilla to do so but in the "/var/www/web/app" folder I am not allowed to upload any files.
I also am not allowed to change any folder permissions. I have only very little knowledge in using a terminal or putty and EC2. How can I upload this one single file to EC2? The online terminal which can be used in EC2 (under "Connect") does not open aswell. I start to pull my hair. I only need to upload this one file because I had to change one single line of code.

Your user has insufficient privileges to make filesystem changes.
You need to log in as the root user using the superuser account and password, which the owner of the EC2 hopefully has.
How did this code get onto the EC2 in the first place if it wasn't placed there by you?

Related

how to recover lost AWS .pem file and putty key, which are lost due to any virus

Yesterday I downloaded Filezilla, after the downloading, I got warn message from my computer, and when I checked the download folder, all data were deleted including putty key and .PPM file. could anyone explain me please, how can I recover these files?
Once you download an AWS pem you can never redownload it again (this is for security purposes if your account was compromised).
Best practice would be store anything of value in an external storage, rather than on a single users machine.
Unfortunately as it stands the instances will not be connectable over SSH without having a PEM. This isn't to say you have lost access to these instances however.
If the individual host is not of importance or can be recreated very easily, you could simply create a new SSH key within AWS and launch new instances using this configuration. You can always create an AMI of the current instances to launch ew one that is identical but specify your new SSH key when you launch.
If the hosts are important AWS support to allow you access the host via a terminal. Before accessing generate a new private/public key and then add the public key to the hosts .ssh/authorized_keys file once you have gained access.
The simplest solution would be to use Sessions Manager to allow you to access the host either via the console or the CLI.
For sessions manager the instances IAM role will need to grant permissions as well as the agent being previously installed.

Unable to SSH into my EC2 instance from a different computer

A little backstory, I have an AWS instance made with Bitnami that I set up on my Windows Machine back home. I am currently out of the country and have no way to access that machine at the moment. One month later, I visit the website getting a 500 error and (only my Macbook on me). I've tried to SSH into it from my Macbook and no luck. I get the error:
Username is not in the sudoers file. This incident will be reported.
I've also tried another way to SSH into my aws but then I just get
Permission denied (publickey).
I do have the public/private keys I made with me so I am not sure if I had to set up some additional permissions to SSH from a different computer. On top of that, I got an email stating that someone attempted to access remote hosts on the internet without authorization. If I visit my Public IP address of my instance, it goes straight to a spam page.
At this point, I am not sure if I am just missing something in my steps or have missed a step. If someone can help me, I would really appreciate it.
Is there some way to get my instance back up and running? If not, is there some way I can back up the wordpress files on that instance that's down and use it to create another one on my Macbook currently? Please let me know.
If you have the private key that your AWS instance has been installed with, place the key in ~/.ssh .
Then, run the following command to set the permissions of the key to read and write only to your user (it's a mandatory step):
chmod 600 ~/.ssh/keyname
Then, run the following command to connect to your instance:
ssh -i ~/.ssh/keyname user#instance_ip
And it should connect successfully.
If you're not sure which user to connect to and you have access to AWS EC2 Console, then look for that server, right-click it and choose "Connect" and it will usually show the correct user to use when connecting to it by SSH.

Automating Certificates Installation automatically using config files in .ebextensions on AWS

My Application is deployed on ElasticBeanStalk on AWS. It is accessing an API that needs SSL certificate to be installed on the instance. I have to manually run the keytool command to import the certificate file every time the instance rebuilds. And whenever EBS rebuilds the EC2 instance, the installed certificates are lost and I have to again transfer the certificate file and install the certificates again.
I think ebextensions can be a solution to this problem but I am not able to understand the exact way to use it.
Please help me with some directions here.
First you need to create the file you want in question, then put it into an S3 bucket. I'd recommend you have it encrypted, and that there's no public permissions on the file for security purposes. From there, in your application root you'll create a .ebextensions folder in your application source root. In there you'll create a .config file named however you want.
This file will need to spell out where to grab the cert you need from and where to put it. The AWS documents spell out how to grab a file from S3 and put it somewhere. The instance profile it's talking about is described here. It's basically a way to allow your instance to talk to S3 without needing to store credentials in a file somewhere. You'll need to make sure it has at least read permissions on the bucket to pull the file.
Once this is all setup beanstalk should have the file on the instance when all is said and done. Another option is to generate a custom AMI with the key already on the file system. Just be aware of the performance considerations it mentions in the document.

Suddenly can't login to filezilla with EC2 amazon server

I have a free EC2 Amazon Ubuntu server and I was connected with putty and filezilla and I was transferring files. Suddenly I lost connection and now whenever I login on either putty of filezilla I get and error saying
Disconnected: No supported authentication methods available (server sent: publickey)
Any ideas what could be possibly happening? I think that before this happened I change the permissions of a folder. Don't know if that's relevant.
I think that before this happened I change the permissions of a
folder. Don't know if that's relevant
Did you change the permission of ~/.ssh directory? ssh expects the directory to have 700 as permission and the ~/.ssh/authorized_key file to have 600 permission. Do you remember what exactly you changed?
You are out of luck if you changed the permissions of ~/.ssh folder. There are other convoluted ways to restore access. You have to stop the instance, attach the root partition to another instance, then change the folder permission, detach the partition, attach it back to your original instance and start it. Search StackOverflow for answers.

How to find a user on Amazon AWS console

There is a user that can log in via FTP on a setup I’m working with. I can’t get a hold of the people who set it up, but it is with Amazon. I wanted to find out how I could see what permissions this FTP user has and how to set up another one for third-party access. I think it may be setup with EC2, but I’m not sure.
The FTP server, if it is running on EC2, has no relationship with your AWS console - it is specific to your instance, and whatever ftp software is running on the server.
You will need to get access to the instance to find out any more information. You can see the key associated with the instance from the console. If you don't have access to that instance, there are ways to get access, but it will involve stopping the instance, mounting the volume to another instance, adding a new key to volume, and then restarting and using that key key to access it.