Glam Prestige Journal

Bright entertainment trends with youth appeal.

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?

1

3 Answers

  1. Run ssh-keygen -f filename.
  2. Run scp filename username@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 username@server.

3

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.

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:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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