System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

SSH key auto authentication Linux

Naj
Valued Contributor

SSH key auto authentication Linux

Hi,

I tried to create ssh key in order easy to me to access into server without key in credential. unfortunately it only for 1st login and after that it's back to normal which is i need to key in manually credential.

May i know is there has any step need to perform to put this permanently?

Thanks

BR
Naj

____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!
5 REPLIES
Alexander Chuzhoy
Honored Contributor

Re: SSH key auto authentication Linux

First create the key (unless already did) with "ssh-keygen -t rsa"

then copy the key to the remote station with
"ssh-copy-id user@machine"

replace the user/machine with the actual username and machine name.


If still doesn't work - check the file /etc/ssh/sshd_config


Pay attention to entries like:
PubkeyAuthentication
PermitRootLogin
all should be set to yes.
Steven Schweda
Honored Contributor

Re: SSH key auto authentication Linux

> I tried to create ssh key [...]

Not a very detailed description of what you
did.

> [...] Linux [...] server [...]

Not a very detailed description of the system
where you did it (or of the other system,
either).

> [...] it only for 1st login and after that it's back to normal [...]

Not a very detailed description of what
happened when you did it.

As usual, showing actual commands with their
actual output can be more helpful than vague
descriptions or interpretations.

As a Forum search for "ssh" should show,
adding "-v" (or "-vv", ...) to an "ssh"
command can provide some diagnostics which
might be helpful. Some authentication
problems leave messages in the system log
file(s). I've never seen a problem where
"ssh" worked only once.


> PermitRootLogin
> all should be set to yes.

Who said anything about user "root" being
involved here?
Naj
Valued Contributor

Re: SSH key auto authentication Linux

Hi Steven Schweda,

May i know what is solution for this issue as far as you understand?
I never seen any solution come out from your end. The main objective is to be able both workstation and server communicating each other via ssh without keyed any credential where is server is Linux and workstation using Linux as well.


Thanks

BR
Naj

____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!
Steven Schweda
Honored Contributor

Re: SSH key auto authentication Linux

> [...] I never seen any solution come out
> from your end. [...]

You probably won't see much from me until you
answer some basic questions, like, say,
"What, exactly, did you do?" and, "What,
exactly, happened when you did it?". With my
weak psychic powers, I can't even guess any
of these things.

> [...] adding "-v" (or "-vv", ...) [...]

Did you try that? What happened?

> As a Forum search for "ssh" should show,
> [...]

Did you look at any of the dozens of old
threads related to "ssh" problems? Some
people have bad file permissions. Some have
bad file ownership. Some have good files in
bad places. Some have bad files in good
places. Believe it or not, there's more than
one possible ssh problem, and it can be hard
to guess which one you're seeing with almost
no useful information to work from.


> [...] Linux [...]

_Whose_ "Linux"?

uname -a
ssh -V
Wilfred Chau_1
Respected Contributor

Re: SSH key auto authentication Linux

system a:
1) login as userA
2) per Alex instruction, generate a key pairs.
**do not enter anything for the passphase if you want password-less authentication.
3) you should now have id_rsa and id_rsa.pub in the .ssh subdirectory under userA's home dir

system b:
1) login as userB
2) vi /home/userB/.ssh/authorized_keys
3) cut/paste content of id_rsa.pub into the file in step (2)

note: for step 2 and 3, better to use Alex's method instead and use ssh-copy-id userB@systemb as userA from systemA

now from system a, login as userA, then ssh to system b as userB. First login will ask you if you want to add system b's host key into your known_hosts file, type yes, next you will be on system b as userB!