Tuesday, 17 May 2016

Setup Trusted connection between two linux servers


Setup Trusted connection between Two linux servers




Server 1 (198.158.5.6)

         user  :  linux


Server 2 (198.160.43.8)


        user  : unix


Now i am going to create the Trusted connection from Server1 - linux user to server2 to unix user.



Before setup trusted connection generate the key pair. if already exist it will over write. please take care of that.


Server 1 (198.158.5.6)

         user  :  linux


ssh keypar generation :-

Switch to 'linux' user in my case and run 'ssh-keygen -t rsa'

Enter and continue with default option. Please don't enter 'passphrase' when it's asking.

root]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/linux/.ssh/id_rsa):
Created directory '/home/linux/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/linux/.ssh/id_rsa.
Your public key has been saved in /home/linux/.ssh/id_rsa.pub.
The key fingerprint is:
63:c7:83:08:2a:85:92:15:e3:4f:18:49:66:c2:ff:9e linux@dedicated2388.inmotionhosting.com
The key's randomart image is:
+--[ RSA 2048]----+
|o.Oo             |
| X.+             |
|+ = o            |
|.. = . . o       |
|. . o . S +      |
| .   . . o .     |
|    . .          |
|     E           |
|                 |
+-----------------+



Server 2 (198.160.43.8)


        user  : unix

Follow the same steps like same as above one. switch to 'unix' user and run 'ssh-keygen -t ras'





Now main steps begin here. I want to enable the trusted connection from 'Server 1' (198.158.5.6) linux user to 'Server 2' (198.160.43.8) unix user.

So login  to 'Server 1' (198.158.5.6)  linux user and change directory to '/home/linux/.ssh/' and copy 'id_rsa.pub' kay


$ cd /home/linux/.ssh/

[test@dedicated2388 .ssh]$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuz3zLfxxxxxxxxxxhxqnQ44YC7L7XnkzLIuLJSDUYEglkNDrdmOx7Me/4o6ZLyrfxh0cQ0LvYvIBQMQUSLE0aIfk1cGNYnNt7R9BiHZfei/3FHcRQ3jUlkd4DMWadJDsASe5uYni6BecmLrSS1PEr/EUBBYXgcngdvP5bOfOd/78u9/VN6+D2FmCNBvCdr6024/qHZ8e7/PPDq7oZ1/Xle1gWGVIWK2wYs8sgGVWRVWNeZf86uHFFHUm2Fd8PGSupUP+9Z9Wd8XQ== linux@xxxxxxxxx



Copy above key and login to 'Server 2' (198.160.43.8)  unix user and change directory to '/home/unix/.ssh/' , create 'authorized_keys' file and paste the above key in 'authorized_keys'  file.


$ cd /home/unix/.ssh/

$ vi authorized_keys

Now give the exicute permission to 'authorized_keys'

$ chmod -x authorized_keys


Now i am able connect the 'Server 2' (198.160.43.8) unix user from Server 1 (198.158.5.6) linux user with out asking the password.


server1-linux $ ssh unix@198.160.43.8

No comments:

Post a Comment