Connecting to the Oracle VM CLI (Command Line Interface) without password


Sometimes you need to work with the command line interface in OVM Manager, for instance if you want to execute several commands in parallel, and it is very hard and boring if you need to put the password each time:

[root@ovmmanager1 ~]# ssh -l admin localhost -p 10000
admin@localhost's password:


Well, here I explain how to configure the access without put the password:

1) ssh

[root@ovmmanager1 ~]# ssh-keygen -t rsa -f ~/.ssh/admin
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/admin.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
SHA256:MTxnKUOehUqMlXfTRpj3Jy7SLRoszH/EmcIWgk5J/jo root@ovmmanager1
The key's randomart image is:
+---[RSA 2048]----+
| +.....=. |
| . =+oo=.+ |
| + =X.++ . |
| * .O. o .|
| o +S+ + = o |
| . = B O o |
| . + * o |
| E o . |
| . . |

[root@ovmmanager1 ~]# cat /root/.ssh/ > /home/oracle/.ssh/ovmcli_authorized_keys

[root@ovmmanager1 ~]# eval `ssh-agent`
Agent pid 865

[root@ovmmanager1 ~]# ssh-add ~/.ssh/admin
Identity added: /root/.ssh/admin (/root/.ssh/admin)

[root@ovmmanager1 ~]# ssh admin@ovmmanager1 -p 10000
The authenticity of host '[ovmmanager1]:10000 ([]:10000)' can't be established.
RSA key fingerprint is SHA256:3rw6ji5BCr3PeAcsKStsk8GrNU8mVaqGiC3dc/rSxC0.
RSA key fingerprint is MD5:f1:0b:f7:8f:39:e5:75:a4:e0:6e:a2:59:d8:fc:d5:32.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[ovmmanager1]:10000,[]:10000' (RSA) to the list of known hosts.


2) script

[root@ovmmanager1 ~]# cat
eval `ssh-agent` >> /dev/null 2>&1
ssh-add ~/.ssh/admin >> /dev/null 2>&1
export ovmUser=admin
export adminServer=ovmmanager1
OVMCLI="ssh -o ServerAliveInterval=40 $ovmUser@$adminServer -p 10000"

ssh-agent -k >> /dev/null 2>&1


One of the most important parts in the script, is the last command (which remove the process ‘ssh-agent’ created at the beginning), without this command, the operating system would be slowed down accumulating the processes ‘ssh-agent’.


3) permissions

[root@ovmmanager1 ~]# chmod 700


4) alias

alias ovmcli='/root/./'


The alias you can add it to the end of the file .bashrc into the $HOME for the user.


If you execute it, you gain access immediatly:

[root@ovmmanager1 ~]# ovmcli


You can put commands directly in the OS prompt:

[root@ovmmanager1 ~]# ovmcli list server
OVM> list server
Command: list server
Status: Success
Time: 2019-01-08 22:32:38,899 CET
id:37:38:36:38:33:30:5a:43:32:38:33:38:30:31:32:33 name:ovmsrv02
id:37:38:36:38:33:30:5a:43:32:38:33:38:30:31:32:32 name:ovmsrv01
OVM> Connection closed.


If you want configure the script for ‘oracle’ user, you can follow the same steps 🙂


Adding value with Arumel!!