-1

I am new to Ubuntu-Linux,i have to create a ssh user in remote system and generate its key. and access this system by key_file through the command.

ssh -i key_file user@host 

Can any body tell me how can i do ?

Hitesh Mundra
  • 1,538
  • 1
  • 9
  • 13
  • possible duplicate of [How do I setup Public-Key Authentication?](http://stackoverflow.com/questions/7260/how-do-i-setup-public-key-authentication) – jas_raj Jan 22 '15 at 17:22

3 Answers3

0

On the system you are trying to connect to, the public key (usually id_rsa.pub or something similar) needs to be added to the authorized_keys file.

If the user is brand new and the authorized_keys file doesn't exist yet, this command will create it for you.

cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys

Next just make sure sshd is running on the host and you should be able to connect with the command you posted.

tgrosinger
  • 2,463
  • 2
  • 30
  • 38
0

on remote-server-

ssh-keygen
   ssh-copy-id user@host 
   cd .ssh

make a copy of the file id_rsa and give any body who want to access this server/system.

on the other system

ssh -i id_rsa user@host
Hitesh Mundra
  • 1,538
  • 1
  • 9
  • 13
0

If you want to connect to another host as user "user", what you need is the public key of the user that is going to open that connection, i.e. the user you are logged in on your desktop computer or some server you are coming from, not for the user, you are logging in to on the remote host.

You can check, if the keys for your current user are already created in $HOME/.ssh; there you should find something like "id_rsa" and "id_rsa.pub" (for rsa keys). If they don't exist, you create them by calling

ssh-keygen -t rsa 

The public key that is generated that way, id_rsa.pub in this example, has to be put in a file ${HOME of user on remote host}/.ssh/authorized_keys on the target host.

If this file does not exist on the remote host or if even .ssh does not exist, you have to create those files with the following permissions:

.ssh                 700
.ssh/authorized_keys 600

See http://www.openssh.com/faq.html#3.14 for details.

A detailed description of the process can be found here:

https://help.github.com/articles/generating-ssh-keys/

nlu
  • 1,903
  • 14
  • 18