Since e.g. SSH keys under Linux are owned by the user who created them, any applications running as the user, e.g. a web browser, should be able to read them from the ~/.ssh folder.

Say that there is only one user on a system: user A. If another user, B, is added to the system and the only purpose of B is to own and store the SSH and GPG keys of user A, applications running as user A should be unable to read the keys.

When user A wants to use the keys that he/she has chosen to store under user B, what would he/she have to? Would this method of storing keys improve the security at all?

Hence, I want the keys to be usable by user A when they are stored by user B, but I don't want the keys to be readable by the applications running as user A.

  • Maybe what you really want is ssh-agent and gpg-agent? – user Apr 1 '16 at 11:20
  • Do you mean creating the keys as user B and somehow loading them into gpg-agent and ssh-agent as user A? If yes, how would one go about to do that? – lklun Apr 1 '16 at 11:36
  • No, I mean isolating the interactions involving secrets to specific, trusted applications that can be audited in ways for example a web browser cannot. It's not a problem if an application can read your private key store. It's only a problem if an application can both read your private key store and have access to the relevant passphrases. – user Apr 1 '16 at 11:42

For example SELinux is probably better answer for your question (you can do that even with users, but it is probably too complicated).

When using SELinux, your private keys are labelled with ssh_home_t (ex. from Fedora) and other applications running in different contexts are not able to access these files, unless explicitly allowed in policy. But ssh client can read them (allowed in policy).

  • This seems to be the best solution. Unfortunately my distro seems to have limited support for SELinux. – lklun Apr 15 '16 at 6:21

I don't see the point in this measure. When you have an untrusted application you should rather run it under a special unprivileged user. Otherwise it would be able to detect how you accessed the files when you need them at some point.

  • It would not necessarily be an untrusted application. Theoretically, every application run as user A should be able to read the keys. In case any of them somehow were to be exploited, it could then be potentially read the keys owned by user A. – lklun Apr 1 '16 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.