Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 176561

How to config ESXi 5.1 to ssh/scp between hosts without password prompt

$
0
0

1) SSH has to be enabled in both hosts. I will not detail this because it's well documented in installation guides.

2) Using vSphere client, go to "Configuration" tab for the host.  Select "Security Profile" option on the left.  Then "Properties" for the firewall section. Captura de pantalla - 130513 - 17:42:42.png

     Check both SSH Server and SSH Client services.

Captura de pantalla - 130513 - 17:44:04.png

3) Login to the console with root user. You can use popular putty in Windows or in linux you can use the command:

    ssh root@xxx.xxx.xxx.xxx

Captura de pantalla - 140513 - 13:18:17.png

(the question "Are you sure.....?" appears only the first time you connect to that server, answer "yes").


4) Verify that .ssh folder exists.

    ls -la /.ssh

Captura de pantalla - 140513 - 13:28:09.png

     if the folder doesn't exist try to connect to the other host. This will create the folder:

     ssh root@xxx.xxx.xxx.xxx


5) Create your private and public key

     /usr/lib/vmware/openssh/bin/ssh-keygen -t dsa

   When prompt for the name of the file in which to save the key, select: /.ssh/id_dsa

   When prompt for passphrase, leave it empty (twice).

Captura de pantalla - 140513 - 15:34:12.png

6) Now you have to export the public key from one host to the other and viceversa. The public key is a text file so you can cut and paste:

     Copy the content of the file /.ssh/id_dsa.pub. In Linux terminal you can display content of the file with more /.ssh/id_dsa.pub and the select the text with mouse and copy it with CRTL+C ór SHIFT+CTRL+C

Captura de pantalla - 140513 - 10:02:34.png

     and add it to the file /etc/ssh/keys-root/authorized_keys on the other host. You can use vi editor:

    vi /etc/ssh/keys-root/authorized_keys

     (press i to enter insert mode, then CTRL+V to paste text, then ESC and finally x and ENTER to save the file).

Captura de pantalla - 140513 - 15:53:10.png

   You can add the public keys of any other host you want to authorize. Be careful to split the lines so each key is on different line.

 

7) There's a problem (I consider it a bug) in ESXI 5: when you reboot the host, all content of .ssh folder is cleared, so, to avoid configuring again, you can do the following steps:

 

   move file known_hosts:  mv /.ssh/known_hosts  /etc/ssh/ssh_known_hosts

   move identity files: mv /.ssh/id_*  /etc/ssh/keys-root/

 

   Now, if you want to ssh "to" this server you can do it as usual, but if you want to ssh "from" this server to another server, you have to use -i (identity) parameter:

   ssh -l root -i /etc/ssh/keys-root/id_dsa  xxx.xxx.xxx.xxx

 

   Note: maybe you need to restart service after you moved files: /etc/init.d/SSH restart

   Be careful to keep a logged terminal session while you test from another terminal session, and if something goes wrong, you can restart files to original locations.

 

I hope it will be useful.


Viewing all articles
Browse latest Browse all 176561

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>