In case you are using WSL on windows
The most simple answer is to just type: sudo ssh -i keyfile.pem <user>@ip
without changing the file permissions.
The reason why this happens?
Another resource
You can't modify the permissions of files on Windows's filesystem
using chmod on Bash on Ubuntu on Windows. You'll have to copy the
private key to your WSL home directory (~) and do it there.
On the other hand, sudo
should never be utilized with ssh. The reason why issuing with sudo
works is that it's now likely being executed as root, and this is not the correct way to do this and is a massive security risk, as Allowing for anything other the 600/400 permissions defeats the purpose of utilizing an SSH key, compromising the security of the key.
The best way to do that is by copying the file to $HOME/.ssh
:
cp keyfile.pem ~/.ssh
Doing sudo chmod 400 keyfile.pem
to it.
Then ssh -i keyfile.pem <user>@ip
.
StrictModes
being enabled on thesshd
server, from the man page: "StrictModes Specifies whether sshd(8) should check file modes and ownership of the user's files and home directory before accepting login." - you could disable this however not suggested.It is recommended
my os showsIt is required
. Maybe my os is newer (2020) and that`s why.Permissions 640 ... are too open
and other OSes such as Unix as well as LinuxTitle cannot contain "ssh "permissions are too open" error"
It tells me "Please provide a title that summarizes your question. For assistance, see: How do I ask a good question?" - which I want to suggest and share here and now.