Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to generate a public-private key on Sever 1 and store it in a location which is not the default location.

Thereafter, save the public key on Server 2; once again NOT at the default location.

Then make this key an authorized key.

However, I cannot find authorized_keys file in ~/.ssh folder. How do I make it authorized?

share|improve this question
1  
ssh-keygen is the command for generating keys. It asks for location of key file during creation. I think you have to create the file authorised key if you don't have one –  sagarchalise Feb 14 '11 at 11:02

3 Answers 3

  1. Run ssh-keygen -f filename.
  2. Run scp filename server:filename-on-server
  3. Log in to the server and run cat filename-on-server >> ~/.ssh/authorized_keys

You could also replace steps 2 and 3 with ssh-copy-id -i filename server.

share|improve this answer

Use ssh-keygen command. On the server (where you want ssh to) store the public key in file ~/.ssh/authorized_keys. If you haven't got an .ssh directory inside your home (~) yet, create it (also be careful: it seems sshd is picky - for security reasons - that no other user can read that file/dir, it's better to issue chmod 700 on your .ssh directory and chmod 600 on the file in it).

On the machine you want to ssh from ("client"), you can use the private key to ssh to your server then. You can store it anywhere then you can use the -i switch of ssh, to give the public key which will be used. I write this, since you stated that "not storing at the default location". The default location would be file id_dsa (for DSA key) inside your .ssh directory. Then you don't need the -i switch to specify your key, because it will be picked from there automatically.

share|improve this answer

Sounds like you've already made the keys. If not, just run ssh-keygen and accept the defaults. Make the authorized_keys file yourself: touch authorized_keys

When you keep your private keys in a non-standard location, make sure and use -i: ssh -i /path/to/privatekey user@host

Here's a good article on ssh-keygen and using authorized_keys to simplify ssh logins:

http://www.debuntu.org/secure-your-ssh-server-with-publicprivate-key-authentification/

share|improve this answer

Your Answer

 
discard

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