I am trying to mount private keys from USB stick. OSx does not allow me to change their permissions, why? How can I change them? In other words, how can I add private keys from random USB stick to ssh-agent?

enter image description here

  • Can you run an ls -l on school to show it's current perms? In addition to the file itself, SSH gets grumpy if the permissions on the directory they're in are open. Make sure that .ssh has restrictive perms, I think 600 is good, from memory. – Alex Nov 16 '12 at 1:09
  • ...err execute permission is too much. Read permission is enough i.e. 400. You can see the current perms in the picture i.e. 777 -- OSx automounts the USB to everyone apparently in the system, now trying to find a way to do it without copying files to the disk. Please, see my answer for a way to solve it, not the safest method but works. – hhh Nov 16 '12 at 1:13
  • You need execute on a directory to see what it's contents are. – Alex Nov 16 '12 at 1:55

I'll bet your USB stick is formatted as FAT, FAT32 or NTFS. OS X's Unix-style permissions are not compatible with FAT and FAT32 filesystems. Additionally, by default, OS X cannot write to NTFS volumes. Make sure the USB stick is formatted as HFS+.

And finally, the file containing the SSH private key must have permissions set to 600 and the folder containing the file must have permissions set to 700

  • Why 600 and not 400? They need just read -access, where do you need write access for files? Any idea how can I create OS X -style fs with non-mac -devices? This is going be a problem if I use many systems. – hhh Nov 16 '12 at 21:22
  • 1
    You can try 400 instead of 600. I suggested 600 because that's what I have on my system. ... To make your USB stick a "Mac device" just format it using Disk Utility.app. – HairOfTheDog Nov 16 '12 at 22:38
  • If 400 you cannot edit it yourself. – Thorbjørn Ravn Andersen Apr 17 '19 at 22:09

You can solve this problem with

$ cp /Volumes/disk/.ssh ~
$ eval `ssh-agent`
$ chmod 400 ~/.ssh/*
$ ssh-add ~/.ssh/school

but this does not solve the original prob i.e. without copying ssh-keys to computer to add keys to the daemon

  • 1
    This worked for me: sudo chmod 600 ~/.ssh/id_rsa – Andrew Hundt Dec 14 '12 at 18:34

As late as OS X 10.13/High Sierra, you can add an /etc/fstab file owned by root, even if it doesn't exist on your system, with the following content:

LABEL=PRIVATE none msdos -u=501,-m=700

This assumes that your user ID is 501 (check with ls -n ~) and that the label of your mounted FAT/ExFAT drive is PRIVATE. I use this for mounting VeraCrypt volume-files with ssh keys (FAT and ExFAT) that I share b/w OS X and Linux. Should work with USB drives as well, but haven't tried exactly that.

You must log in to answer this question.

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