20

I keep an SSH private key file on a separate USB thumb drive (encrypted), but when I try to use it to connect to my remote host I get an error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/Volumes/USB/id_rsa' 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: /Volumes/USB/id_rsa
Permission denied (publickey).

I've tried changing the permissions on the keyfile (chmod 600 id_rsa), but it still looks to be set to 777 (change not taking effect). This is on Mac OS X.

Any idea how to fix it?

0

5 Answers 5

9

What type of filesystem do you have on your USB stick? If it is one of the FAT filesystems, FAT8, FAT16, VFAT, FAT32, then you're probably out of luck, as they do not have fields to store Unix-style permission bits. (The UMSDOS filesystem driver for Linux does hack this up, but I doubt OS X has anything that hacky available. :)

If it is NTFS or NTFS2, then perhaps there can be some mapping made, but I wouldn't count on it.

If it is HFS+ or UFS, then definitely more details are needed, because it ought to work as you've described, but symlinks could get in the way.

1
  • 5
    Is there anyway to tell SSH to just ignore the permissions problem? Or is this hard coded into it?
    – Hengjie
    Oct 31, 2012 at 3:18
15

This is a permissions issue on a Mac. The file system is HFS+, so the first comment is incorrect by far. Permissions are the basic foundation of the *nix OS, so it would behoove you to understand.

$ chmod 600 /Volumes/USB/id_rsa
1
  • Got a key from windows. This fixed my problem on Linux.
    – aloisdg
    Jun 28, 2019 at 9:02
4

I think chmod 600 /Volumes/USB/id_rsa is sufficient.

0

Your flash drive is probably pre-formatted to FAT32, which does not support Unix-style permissions. Reformat your flash drive to a better file system (HFS+ comes to mind, since you're on Mac).

0

I had the same issues I had done like this to solve out my problem.

here is the Solution ::

Solution : Add correct host key in /home/user/.ssh/known_hosts

It is not necessary to delete the entire known_hosts file, just the offending line in that file. For example if you have 3 server as follows.

myserver1.com,64.2.5.111 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA11FV0EnGahT2EK8qElocjuHTsu1jaCfxkyIgBTlxlrOIRchb2pw8IzJLOs2bcuYYfa8nSXGEcWyaFD1ifUjfHelj94AAAAB3NzaC1yc2EAAAABIwAAAIEA11FV0E
nGahT2EK8qElocjuHTsu1jaCfxkyIgBTlxlrOIRchb2pw8IzJLOs2bcuYYfa8nSXGEcWyaFD1ifUjfHelj94H+uv304/ZDz6xZb9ZWsdm+264qReImZzruAKxnwTo4dcHkgKXKHeefnBKyEvvp/2ExMV9WT5DVe1viVwk=
myserver2.com,125.1.12.5 ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAQEAtDiERucsZzJGx/1kUNIOYhJbczbZHN2Z1gCnTjvO/0mO2R6KiQUP4hOdLppIUc9GNvlp1kGc3w7B9tREH6kghXFiBjrIn6VzUO4uwrnsMbnAnscD5EktgI7fG4ZcNUP 5+J7sa3o+rtmOuiFxCA690DXUJ8nX8yDHaJfzMUTKTGxQz4M/H2P8L2R//qLj5s3ofzNmgSM9lSEhZL/IyI4NxHhhpltYZKW/Qz4M/H2P8L2R//qLj5s3ofzNmgSM9lSEhZL/M7L0vKeTObue1SgAsXADtK3162a/Z6MGnAazIviHBldxtGrFwvEnk82+GznkO3IBZt5vOK2heBnqQBfw=
myserver3.com,125.2.1.15 ssh-rsa 
5+J7sa3o+rtmOuiFxCA690DXUJ8nX8yDHaJfzMUTKTGx0lVkphVsvYD5hJzm0eKHv+oUXRT9v+QMIL+um/IyI4NxHhhpltYZKW
as3533dka//sd33433////44632Z6MGnAazIviHBldxtGrFwvEnk82/Qz4M/H2P8L2R//qLj5s3ofzNmgSM9lSEhZL/M7L0vKeTObue1SgAsXADtK3162a/Z6MGnAazIviHBldxtGrFwvEnk82+GznkO3IBZt5vOK2heBnqQBfw==

To delete 2nd server (myserver.com), open file:

# vi +2 .ssh/known_hosts

And hit dd command to delete line. Save and close the file. Or use following

$ vi ~/.ssh/known_hosts

Now go to line # 2, type the following command

:2

Now delete line with dd and exit:

dd
:wq

Check out this full video Tutorial based on your problem:

SSH Host Key Change Error

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .