ssh -i suse-ec2-server-jp.pem root@ec2-xx-yy-zzz-yyy.compute-1.amazonaws.com
I am getting the following error:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0440 for 'suse-ec2-server-jp.pem' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: suse-ec2-server-jp.pem
Password:
How do I fix this problem and login using ssh command?
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | chmod/OpenSSH |
Time | N/A |
chmod command syntax to fix file warnings
The syntax is:
chmod 0400 file
chmod 0400 /path/to/file
If suse-ec2-server-jp.pem is located in $HOME/.ssh/ directory, try:
## set permission on file ## chmod 0400 $HOME/.ssh/suse-ec2-server-jp.pem ## Make sure dir containing the suse-ec2-server-jp.pem private key and other files set to 0700 chmod 0700 $HOME/.ssh/
Verify permissions with the ls -l command:
ls -ld $HOME/.ssh/ ls -l $HOME/.ssh/suse-ec2-server-jp.pem
Now, try ssh command as follows:
## for ubuntu Linux # ssh -i $HOME/.ssh/suse-ec2-server-jp.pem ubuntu@ec2-xx-yy-zzz-yyy.compute-1.amazonaws.com ## for Suse ## ssh -i $HOME/.ssh/suse-ec2-server-jp.pem ubuntu@ec2-xx-yy-zzz-yyy.compute-1.amazonaws.com ## For freebsd ## ssh -i $HOME/.ssh/suse-ec2-server-jp.pem root@ec2-xx-yy-zzz-yyy.compute-1.amazonaws.com
Sample session:
Fig.01: Fixing “WARNING: UNPROTECTED PRIVATE KEY FILE!” on Linux/MacOS X/FreeBSD/Unix
Please note that this is not AWS EC2 or Ubuntu/Suse Linux or Apple OS X specific issue. This is an OpenSSH client specific security related issue. See ssh man page for more information.
ð§ 3 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
change the permissions of ur key chmod 600 yourkey
more specifically, your .ssh/ directory should have permission of 700
your authorized_keys file should have permission of 600
Explanations about this problem are very unuseful