fbpx

How to fix WARNING: UNPROTECTED PRIVATE KEY FILE!

WARNING: UNPROTECTED PRIVATE KEY FILE!

I got this error and I could not figure out the issue. Finally, I got something else that was not documented and frustrated me a lot. I was using my /home/thedbadmin/.ssh/config file for password less sftp. In place of the private key, I have mentioned my public key location inside the config file.  I thought I will share this with everyone so that if they are using sftp password less connection using config file they can fix it fast.

Error:

sftp thedbadmin
You are authorized to use this System for approved business purposes only. Use for any other purpose is prohibited. All transactional records, reports, e-mail, software, and other data generated by or residing upon this System are the property of the Company and may be used by the Company for any purpose. Authorized and unauthorized activities may be monitored.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/thedbadmin/.ssh/rsa_thedbadmin.pub' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/thedbadmin/.ssh/rsa_thedbadmin.pub": bad permissions
Password Authentication
Password:

Fix:

In my case, I have just change the file from rsa_thedbadmin.pub (public) to rsa_thedbadmin (private)

How should ‘~/.ssh/config’ look like

Host test_sftp_thedbadmin
HostName pub.sftp.thedbadmin.com
User user123
Port 22
IdentityFile /home/thedbadmin/.ssh/rsa_thedbadmin

 

Default Permission level for RSA public and private files. It should also need to be corrected.

1. Make sure you have  private key path inside the ~/.ssh/config in case if you are using ~/.ssh/config
2. Change the ssh private and public key privilege according to the following permission.

RSA/DSA Private file permission: - rw-------  = 600
RSA/DSA Public file permission : - rw-r--r--  = 644

I hope this will fix your issue. Comment in case you have any questions.

Share:

Facebook
Twitter
Pinterest
LinkedIn

Social Media

Most Popular

Get The Latest Updates

Subscribe To Our Weekly Newsletter

No spam, notifications only about new products, updates.

Categories