Sie sind auf Seite 1von 2

Login to <<HOSTSERVER>>

sudo su - root
identify if user <<userid>> is exist then delete to create from scratch.
[root@HOSTNAME ~]$ userdel -r <<userid>>
create a new group <<userid>>
[root@HOSTNAME ~]$ groupadd <<userid>>
#Encrypt your password using below command
[root@HOSTNAME ~]$ openssl passwd -crypt <<userpassword>>
create new user <<userid>> and assign to group <<userid>>
[root@HOSTNAME ~]$ useradd -m -c "Application User" -p <<encriptedpassword>> -g
<<userid>> <<userid>>
verify newly created user
[root@HOSTNAME ~]$ cat /etc/passwd | grep <<userid>>
[root@HOSTNAME ~]$ id <<userid>>
Try to login to the user, for which the password would be "<<userpassword>>"
[<<userid>>@HOSTNAME ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/<<userid>>/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/<<userid>>/.ssh/id_rsa.
Your public key has been saved in /home/<<userid>>/.ssh/id_rsa.pub.
The key fingerprint is:
19:0b:a7:37:47:f6:2f:a2:c4:03:10:54:c3:f3:86:8b <<userid>>@HOSTNAME
The key's randomart image is:
+--[ RSA 2048]----+
|
+. ... |
|
. = . . . |
|
. E O o . .|
|
= B * . . |
|
S * o
|
|
o +
|
|
|
|
|
|
|
+-----------------+
[<<userid>>@HOSTNAME ~]$
total 16
drwx------. 3 <<userid>>
-rw-------. 1 <<userid>>
-rw-r--r--. 1 <<userid>>
drwx------. 2 <<userid>>

ls -lart .ssh
<<userid>>
<<userid>>
<<userid>>
<<userid>>

4096
1675
418
4096

Apr
Apr
Apr
Apr

26
26
26
26

13:11
13:16
13:16
13:16

..
id_rsa
id_rsa.pub
.

[<<userid>>@HOSTNAME ~]$ ssh <<remoteuserid>>@<<REMOTEHOSTIP>> mkdir -p .ssh


[<<userid>>@HOSTNAME ~]$ cat .ssh/id_rsa.pub | ssh <<remoteuserid>>@<<REMOTEHOST
IP>> 'cat >> .ssh/authorized_keys'
or alternatively use below command

[<<userid>>@HOSTNAME ~]$ ssh-copy-id <<remoteuserid>>@<<REMOTEHOSTIP>>


The authenticity of host '<<REMOTEHOSTIP>> (<<REMOTEHOSTIP>>)' can't be establis
hed.
RSA key fingerprint is ab:9f:88:c3:16:3a:b6:b4:66:49:fd:51:c0:ae:3f:5b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '<<REMOTEHOSTIP>>' (RSA) to the list of known hosts.
<<remoteuserid>>@<<REMOTEHOSTIP>>'s password: <<remoteuserpassword>>
Now try logging into the machine, with "ssh '<<remoteuserid>>@<<REMOTEHOSTIP>>'"
, and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
Due to different SSH versions on servers, we need to set permissions on .ssh dir
ectory and authorized_keys file.
[<<userid>>@HOSTNAME ~]$ ssh <<remoteuserid>>@<<REMOTEHOSTIP>> "chmod 700 .ssh;
chmod 640 .ssh/authorized_keys"
From now onwards you can log into <<REMOTEHOSTIP>> as <<remoteuserid>> user from
server <<HOSTSERVERIP>> as <<userid>> user without password.
[<<userid>>@HOSTNAME ~]$ ssh <<remoteuserid>>@<<REMOTEHOSTIP>>
if that doesn't work, login to <<REMOTEHOSTIP>> as user <<remoteuserid>> and run
the following command
[<<remoteuserid>>@HOSTNAME ~]$ restorecon -R -v ~/.ssh
refer http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-s
teps/ and
http://stackoverflow.com/questions/9741574/redhat-6-oracle-linux-6-is-not-allowi
ng-key-authentication-via-ssh for troubleshooting.

Das könnte Ihnen auch gefallen