Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up public key authentication using this guide:

The documentation talks about the ~/.ssh/authorized_keys file, but there is no ~/.ssh/authorized_keys file is my home directory.

Should this file be generated automatically?

The Maverick sshd man page does not specify whether the file is created when OpenSSH is installed, or whether the file should be created manually.

I just wondered if the absence of this file is normal before I create it myself.

share|improve this question
up vote 9 down vote accepted

~/.ssh/authorized_keys is a per-user file. Installing a unix program never writes to users' home directories. So by default the file will not exist (which has the same effect as an empty file).

If you're generating the key on a client that is also running OpenSSH, use ssh-copy-id [as described] to transfer the public key to the server, using for that one time your password to log into the server.

If you're generating the key by some other method, copy the file from where you generated the key to ~/.ssh/authorized_keys on the server (create the directory ~/.ssh if necessary). Make sure that all three of your home directory, ~/.ssh and ~/.ssh/authorized_keys are writable only to the user (no group or other write permissions). If you want to authorize more than one key, just concatenate them into ~/.ssh/authorized_keys (so ~/.ssh/authorized_keys has one public key per line).

If you use something other than OpenSSH to generate the key, you might need to convert the public key to the OpenSSH format. For example, in PuTTY, use ‘Public key for pasting into authorized_keys file’.

share|improve this answer
Excellent response, thanks for your help. That makes sense. – unpossible Apr 3 '11 at 18:36
to highlight one of the points mentioned above: "no group or other write permissions" -- having group write permission on the authorized_keys file was the only thing preventing public key authentication from working on a machine here and had me running in circles. +1! – rymo Jul 21 '11 at 18:44

From that page:

The private key is kept on the computer you log in from, while *the public key is stored on the .ssh/authorized_keys file* on all the computers you want to log in to.

When creating a keyfile using ssh-keygen, you'll get files named id_rsa and The first is your private key (possibly password-protected) and should be kept secret all times. You are the client.

The latter is your public key which can be given to the other side, the server. The server can allow multiple public keys. The key files are plaintext files, so you can open them with any text-editor. The public keyfile has just one line, this line should be added to the ~/.ssh/authorized_keys file on the server.

The private and public keys below are generated using ssh-keygen -t rsa. The previous command created the files ~/.ssh/id_rsa and ~/.ssh/

A private key file ~/.ssh/id_rsa looks like:

Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,6D5AD2DF5464E16B4E92E81D095A5E7E

...23 lines omitted...

The corresponding public key ~/.ssh/ looks like:

ssh-rsa AAAAB3NzaC1yc2EA[some chars omitted]X3aKKB6lOyr0v user@host

The first word is either ssh-rsa (for RSA keys) or ssh-dss (for DSA keys). The second part (AAAAB3...r0v) is the actual data. user@host is just a comment, and could be replaced with anything, like sysadmin from home.

share|improve this answer

Just create it using your favorite editor or touch, but make sure it has the right permissions.

chmod 400 ~/.ssh/authorized_keys
share|improve this answer

Yea, its normal. Simply create one when you want to add ssh-keys.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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