ssh login in ec2 to change file permission - amazon-ec2

I need to login in the ec2 aws server to change the file permission. I've .pem and .ppk file on my server and gitbash installed.
Please guide me how can I login to the server and change the file permission.

Here the official documentation from Amazon with SSH/Putty tutorials to connect to your instance: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html
(But assuming you are using Unix/Linux OS)
You could log in to the ec2 instance with the command:
ssh -i /route/to/your/file.pem user#serverUrl.com
(if you have public Url or in your /etc/hosts file or with your IP)
Then, you are logged in the EC2, you could cd to the desired folder and change the permisions with a chmod.
In the /etc/hosts file, you could change the IP of your instance for the serverUrl.com like:
XX.XX.XX.XX serverUrl.com
Hope this helps!

Related

scp from remote server to ec2-instance

I want to copy a folder from remote ubuntu to ec2-instance tried the below at remote ubuntu machine
scp -i </path/of/ec2_pemkey> -r <folder that I wanna copy> user#<ip of ec2>:/path/where/I wanna/copy
I copied my pem to remote and changed permissions chmod 400
error: connection timed out
The Connection Time out means that your local can't be able to reach the remote.
to debug :
Check if your remote machine authorize traffic from port 22 ( Security Group)
Check if You have the good public IP of your machine
If its was an error with your pem key or user (ubuntu) you will receive an access denied error.
From you comment, that means its was the IP of the machine missing or not good.
I missed adding ip address of my remote ubuntu machine to security groups of my ec2 instance. Once done, I was able to scp from remote ubuntu to ec2 instance.
Make sure security group type is SSH which enables port 22

Unable to connect to AWS instance even after manually adding in public key to authorized_keys

I am unable to run an ansible-playbook or use ansible ping on a AWS instance. However, I can ssh into the instance with no problem. My hosts file is this:
[instance]
xx.xx.xxx.xxx ansible_ssh_user=ubuntu ansible_ssh_private_key_file=/home/josh/Ansible/Amazon/AWS.pem
Should I not use a direct path. I am trying to use ansible to install apache onto the server. In my security group in the AWS console, I allowed all incoming ssh traffic in port 22, and ansi
service: name=apache2 state=started`ble tries to ssh through port 22 so that should not be the problem. Is there some crucial idea behind sshing into instances that I didn't catch onto to. I tried following this post: Ansible AWS: Unable to connect to EC2 instance but to no avail.
make sure inside ansible.cfg ***
private_key_file = path of private key(server-private-key)
and in host machine don't change default authorized_keys file ,better way is create one user, for that user create .ssh directory and then inside create a file called authorized_keys & paste your server-public key
$~/.ssh/authorized_keys
try: ansible-playbook yourplaybookname.yml --connection=local
ansible defaults to ssh

Adding pem key to jenkins box

I have a jenkins box, I have ssh in to it and from there I want to access one of the Ec2 instance in AWS, I tried ssh -i "mykeyname.pem" ec2-user#DNSname but It throws me an error "Permission denied (publickey,gssapi-keyex,gssapi-with-mic)".
I have the PEM file of the EC2 instance I want to connect. But is there any way I can ssh in to the instance..?
There are two possible reasons.
Default user name is not "ec2-user"
Please check your using image "jenkins box".
If it doesn't use "ec2-user", change user name for ssh commands
Your key-pair is incorrect
Once you created EC2 instance with correct key-pair, you could access EC2 instance with such commands
Please check your using key-pair name
FYI
Connecting to Your Linux Instance Using SSH

Laravel "envoy run" command not working with ssh key

I am running following command in a laravel project folder and getting following error.
rakib$ envoy run list --env=production
[ubuntu#54.187.123.4]: Permission denied (publickey).
But I can successfully ssh using following command:
ssh -i ~/.ssh/sw-new.pem ubuntu#54.187.123.4
My ~/.ssh/config file content looks like:
Host 54.187.123.4
IdentityFile ~/.ssh/sw-new.pem
Can anyone suggest me what is the possible reason of getting "Permission denied" error?
It's possible that envoy is using the wrong user when attempting to ssh into the production server. Specify a user in your ~/.ssh/config file:
Host 54.187.123.4
IdentityFile ~/.ssh/sw-new.pem
User ubuntu
That should work.
It is possible as answer above for AWS user when you attempting to ssh in production mode, after define "config" file as "~/.ssh/config":
Host ec2-52-29-45-15.eu-central-2.compute.amazonaws.com
IdentityFile /home/tux/Desktop/ssh/masterpro.pem
User ubuntu

Unable to access website added in hosts file in MAC OSX

I have added a hostname in the /etc/hosts/ file in Mac OSX,when i try to run the URL with the hostname in the browser i couldn't able to access it , but when i try to access it with IPAddress I could able to access it.
Observations:
1)I can able to ping both IPAddress and hostname added to /etc/hosts file
2)I can able to access the URL with IPAddress but not with hostname
3)I tried flushing the dns Cache with following command
dscacheutil -flushcache
4)I can able to access URL with hostname in windows machine.
So I appreciate any suggestions about what might have gone wrong....
Thanks in advance....

Resources