Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Network Services»SSH»SSH with Private Key – WARNING: UNPROTECTED PRIVATE KEY FILE

    SSH with Private Key – WARNING: UNPROTECTED PRIVATE KEY FILE

    RahulBy RahulSeptember 22, 20152 Mins ReadUpdated:December 16, 2019

    I have launched a new Linux instance in my AWS account and downloaded the private key file. As we all know, AWS only allows default key-based SSH authentication. When I tried to SSH with the downloaded private key file, I got the following warning message on-screen and then it prompts for the password of the user.

    Error:

    The error looks like below:

    ssh -i server.pem [email protected]
    
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0644 for 'server.pem' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    bad permissions: ignore key: server.pem
    [email protected]'s password: 
    

    I was aware of this issue, so I got it fixed easily. If we read the error message carefully, we will understand that there are some issues with the permissions on the server.pem file.

    So this tutorial is for our readers to quickly solve this issue without wasting their time. Thanks

    Solution:

    As per security policy, the private key file must not be publicly viewable in order to successfully log in to the server using SSH protocol. So you need to change the file permissions to restrict access to the owner only. The owner only required the read permission to use this file during ssh connection. Change the file permissions with the following command:

    chmod 400 server.pem
    

    Now try to ssh with the same command and same key file.

    ssh -i server.pem [email protected]
    

    You will be able to ssh properly to the remote server without any error message.

    error private key SSH warning
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Enable SSH as root on AWS Ubuntu Instance
    Next Article How to Extract Filename & Extension in Shell Script

    Related Posts

    (Resolved) userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms

    Updated:May 10, 20221 Min Read

    Adding a New SSH Key in GitHub

    Updated:April 1, 20223 Mins Read

    How to Create SFTP Only User in Debian 11

    Updated:September 26, 20214 Mins Read

    How to Disable Strict Host Key Checking in SSH

    Updated:September 25, 20212 Mins Read

    How To Set Up SSH Keys in Linux

    5 Mins Read

    How To Set Up SSH Tunneling

    5 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.