411
210
I changed my permissions in my .ssh
folder and now when I use a piece of software that uses my private key, I have to type my password each time. What should my permissions be on my id_rsa
file to not have to type a password each time I use an app that uses it?
Currently my permissions are set to:
-rw-------@ 1 Jody staff 114 Nov 4 23:29 config
-rw------- 1 Jody staff 1743 Oct 21 2009 id_rsa
-rw-------@ 1 Jody staff 397 Oct 21 2009 id_rsa.pub
-rw-------@ 1 Jody staff 3855 Sep 13 22:35 known_hosts
15I found elsewhere that if using the authorized_keys file, that it should be chmod'd to 640, ie -rw-r----- . – AnneTheAgile – 2014-09-11T21:19:10.687
7Where I can find this info in man pages? – Sonique – 2014-11-17T15:56:40.213
147I have come back to this post about 30 times now. I cant believe I cant remember it. – JREAM – 2015-04-02T21:35:39.333
2You can also safely leave the
.ssh
directory permissions at755 (drwxr-xr-x)
, as well as theid_*.pub
andauthorized_keys
permissions at644 (-rw-r--r--)
. Otherwise other users cannot lookup your public keys, but being able to do so is often convenient if they need to know your public keys to grant you access to some service. – Markus Kuhn – 2015-09-30T11:55:15.4478The only important things are that nothing in .ssh is writeable to anyone else and none of the secret keys are readable to anyone else. – Markus Kuhn – 2015-09-30T11:56:19.113
1
@MarkusKuhn OpenSSH specifies
– augurar – 2016-02-18T01:52:13.013600
forauthorized_keys
for some reason (link).1@augurar My guess: a world-readable
authorized_keys
file would expose the (public) keys that an attacker could use to gain full access to your account. They'd still need to find one of the private keys, of course. – David Harkness – 2016-06-14T20:08:36.1531To let others verify your signatures and encrypt files for you, make the public key files (
*.pub
) world-readable and the.ssh
folder world-readable and -executable. Without the latter, other users won't be able to view the public key files. – David Harkness – 2016-06-14T21:02:50.7173Why 700? Why would you need anything under
~/.ssh
to be executable? – Cerin – 2016-10-26T16:39:36.8501Why, after generated, would private key be writeable (600)? Generate the keys, then lock down the folder, no? – xtian – 2016-11-20T17:49:16.477
2The correct permissions for
~/.ssh/config
are600
. – Florian Brucker – 2016-12-02T08:32:43.9036@Cerin execute permission on a directory grants the ability to list immediate child files/dirs of that directory, files inside the folder don't "inherit" the execute bit of their parent folder. – Thomas – 2017-01-29T08:42:32.260
2At least some versions of OpenSSH require home directory permissions such that only the user can write the home directory. Otherwise,
~/.ssh
could be replaced by a link, and an arbitraryauthorized_keys
file substituted. – Adam Glauser – 2017-08-03T13:12:01.2871I get
Permissions 0644 for '/home/user/.ssh/id_rsa.pub' are too open.
on Debian Buster. – Akito – 2019-11-20T20:41:25.787This answer cannot be correct as the directory is more restrictive than the public key. – Lloyd Dewolf – 2020-01-17T16:09:48.817