Not able access a file when using chmod 400 - linux

I need to give a user in AWS permission to a key pair using chmod 400 command, but when I do that in the terminal I get an error as attached
devmoki#devmoki-HP-250-G2-Notebook-PC:~$ sudo chmod 400 jenkinskeypair.pem
chmod: cannot access 'jenkinskeypair.pem': No such file or directory
Have also do this
devmoki#devmoki-HP-250-G2-Notebook-PC:~$ sudo !!
sudo chmod 400 jenkins us-west-2 jenkinskeypair.pem
[sudo] password for devmoki:
chmod: cannot access 'jenkins': No such file or directory
chmod: cannot access 'us-west-2': No such file or directory
chmod: cannot access 'jenkinskeypair.pem': No such file or directory
still getting the same error any assist on the same

Based on comments. The key was found.
Useful materials with AWS provided info about connection to EC2 are:
Connecting to your Linux instance using SSH
New: Using Amazon EC2 Instance Connect for SSH access to your EC2 Instances

Related

How to resolve /bin/bash: Permission Denied

RHEL8.3 OS is being used on server, Yesterday i have accidently executed command chmod 644 /* from /usr/share/fonts directory after command execution i am not able to access server with ssh or on putty.
Admin is trying to connect to server with root user but he is getting error /bin/bash: Permission Denied.
Please suggest how to restored permissions or resolve issue.
Refer to here, 644 means you can't even execute the file, with or without root.
Permissions of 644 mean that the owner of the file has read and write access, while the group members and other users on the system only have read access.
Could you try sudo chmod 755 /* or without root chmod 755 /*?
Also, you may try this.
If nothing works, reinstalling your system will be the only choice left.

mkdir: cannot create directory ‘/mnt/var/log/spark-jobserver\r’: Permission denied

I was trying to deploy spark-jobserver on a EMR cluster, as per this documentation "https://github.com/spark-jobserver/spark-jobserver/blob/master/doc/EMR.md#configure-master-box"
Was able to install the job-server on emr, but while starting the server using ./server_start.sh on "/mnt/lib/spark-jobserver" (you can find it in my cluster), it was showing
"mkdir: cannot create directory ‘/mnt/var/log/spark-jobserver\r’: Permission denied".
I have tried to give permission to it using chmod and also tried chown command, but all of these didnt work.
Further I had also tried logging in with ec2-user, but this even didnt help.
Can you please tell what more else is needed to be done in order to get it deployed on emr, or emr is not capable of doing this.
Logs:
[hadoop#ip-10-0-0-50 spark-jobserver]$ ./server_start.sh
mkdir: cannot create directory ‘/mnt/var/log/spark-jobserver\r’: Permission denied
Did you try giving permissions recursively?
chmod -R 777 dirname

Unable to SSH into EC2 Instance pem 'Permissions 0777 for '.ssh/intuit-tke-qe.pem' are too open'

I'm unable to ssh into my EC2 instance, seems to be an issue with the permission level of the ssh .pem file I'm passing to ssh, googling around this seems to be a problem many others have faced but their solutions didn't work for me.
Here is what I tried, someone please help...
Atempt 1:
asemani$ ssh -i ~/.ssh/secure.pem root#54.210.0.1
********************************************************************************
This is a private computer system containing information that is proprietary
and confidential to the owner of the system. Only individuals or entities
authorized by the owner of the system are allowed to access or use the system.
Any unauthorized access or use of the system or information is strictly
prohibited.
All violators will be prosecuted to the fullest extent permitted by law.
********************************************************************************
###########################################################
# WARNING: UNPROTECTED PRIVATE KEY FILE! #
###########################################################
Permissions 0777 for '.ssh/secure.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key ".ssh/secure.pem": bad permissions
Permission denied (publickey).
Attempt 2:
asemani$ chmod 600 ~/.ssh/secure.pem
asemani$ ls -l ~/.ssh/
total 56
-rw-r--r-- 1 asemani CORP\Domain Users 782 Apr 29 11:14 config
-rw-------# 1 asemani CORP\Domain Users 1696 Apr 29 21:32 secure.pem
asemani$
asemani$ ssh -i .ssh/secure.pem root#54.210.0.1
********************************************************************************
This is a private computer system containing information that is proprietary
and confidential to the owner of the system. Only individuals or entities
authorized by the owner of the system are allowed to access or use the system.
Any unauthorized access or use of the system or information is strictly
prohibited.
All violators will be prosecuted to the fullest extent permitted by law.
********************************************************************************
Permission denied (publickey).
I don't get the warning anymore but Permission is still denied. I then also tried doing a chmod 400 on the .pem file but that also didn't work. I won't paste that here since that may be overkill.
What is happening here? How can I ssh into my ec2? This should be a simple thing??
Change permission to chmod 400 ~/.ssh/secure.pem
Are you able to login as the default user using your pem key? For Ubuntu instances, default user should be ubuntu; for most other instances it should be ec2-user. If you're able to login as the default user, chances are that root isn't allowed for ssh login. To change that, login as the default user and do the following:
# Edit sshd_config and modify 'PermitRootLogin XX' to 'PermitRootLogin yes'
sudo vi /etc/ssh/sshd_config
# Reload sshd configuration
sudo service sshd reload
NOTE: This only serves as a how-to. It's generally not recommended to allow root login over ssh for security reason.
You need to launch the instance through your AWS EC2 management console. Once it is launched, copy the public DNS IPv4 and paste it after the linux distribution name being used (e.g. ubuntu#IPv4). Also, make sure you are working in the directory that houses your private access key.
For clarification, once your EC2 instance is launched and you're in the directory that holds your private access key, type in the following in the command-line:
ssh -i private_access_key.pem linux#IPv4
to windows users can change the premise of files through wsl doing this:
Edit or create (using sudo) /etc/wsl.conf
[automount]
options = "metadata"
Restart wsl: (powershell)
PS Get-Service LxssManager | Restart-Service
and finally, do:
chmod 400 key.pem

AWS - Access the volume and fix own of the folders

My server was perfect until I used some chown commands.
So after that I even could not connect via putty or FTP.
I received:
Server refused our key.
So then I created a new instance and attached my volume to it.
I had mounted the volume but i cannot access anything because every folder is permission denied
What should I do? It is getting me crazy!
Change the user from 'ec2-user' to 'root' using sudo su and then you will be able to access all the directories.

Not able to connect to remote Amazon Instance via SSH (Permission denied(publickey))

Can anyone help me fix this issue, I am trying to access Amazon Instance via ssh from another amazon instance, but I am getting the following error-
[ec2-user#ip-172-31-28-27 jmeter-ec2-master]$ ssh -i "JmeterCloud-Updated.pem" ec2-user#ec2-52-38-189-49.us-west-2.compute.amazonaws.com
Permission denied (publickey).
Any help will be much appreciated
Did You Use the chmod command to make sure your private key file isn't publicly viewable. For example, if the name of your private key file is my-key-pair.pem, use the following command:
chmod 400 /path/my-key-pair.pem
Use the following:
chmod 600 JmeterCloud-Updated.pem
to give adequate access to the key and then try to login into that instance.

Resources