[Solved] Encrypted VM starting from command line

Discussions related to using VirtualBox on Linux hosts.
Post Reply
JW8888
Posts: 9
Joined: 13. Feb 2018, 19:38

[Solved] Encrypted VM starting from command line

Post by JW8888 »

Hi,

I've created a VM via the GUI interface on Xubuntu 16.04 64bit, the VM is encrypted and will start without problem from the GUI.

However I want to be able to start this VM on the same PC when the OS graphical interface is off and so in headless mode.

Starting the VM with:

Code: Select all

VBoxHeadless --startvm "whatever"
results in the VM starting up 'paused'
VBoxManage controlvm "whatever" resume
- does not work, remains paused

I have tried
VBoxHeadless --startvm "whatever" && VBoxManage controlvm "whatever" addencpassword "identifier" -
which sometimes allows me to enter a password and sometimes does not, but either way the machine is still paused and will only be rescued by switching on the OS graphical & saving state & then resuming - all from GUI.

So all functions with GUI, but where am in going wrong with command line..?

Any help much appreciated..!
Last edited by socratis on 14. Feb 2018, 00:49, edited 1 time in total.
Reason: Marked as [Solved].
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Encrypted VM starting from command line

Post by socratis »

JW8888 wrote:
VBoxManage controlvm "whatever" resume
- does not work, remains paused
Good. It's not supposed to resume as simply as that, you need to enter the password. See ch. 9.31.3 Starting a VM with encrypted images.
JW8888 wrote:I have tried
VBoxHeadless --startvm "whatever" && VBoxManage controlvm "whatever" addencpassword "identifier" -
which sometimes allows me to enter a password and sometimes does not
I highly doubt that it sometimes it works and sometimes it doesn't. That's not a deterministic way. It works fine with the following commands:
$ VBoxHeadless -s "<MyVM>" -v off &
[1] 4516
Oracle VM VirtualBox Headless Interface 5.2.97
(C) 2008-2018 Oracle Corporation
All rights reserved.

$ VBoxManage controlvm "<MyVM>" addencpassword "<MyVM>" -
Enter password:
The only unclear part in the manual (for me at least) was that for the "id" part, I had to use the name of the VM, since I used the GUI and I didn't include specifically an ID. I guess it defaults to the VM name. I had to open the .vbox file to see the following:
<Property name="CRYPT/KeyId" value="MyVM"/>
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
JW8888
Posts: 9
Joined: 13. Feb 2018, 19:38

Re: Encrypted VM starting from command line

Post by JW8888 »

Hi socratis, thanks for your reply!

I should have explained that the resume function doesn't work even after I have entered a password
I highly doubt that it sometimes it works and sometimes it doesn't. That's not a deterministic way.
So what usually happens with my commands, is that I get the password prompt, but occasionally, after I've been trying to start & stop the VM from command line a few times, the same command doesn't produce the password prompt but it seems as if the process / terminal / something - has crashed.

I noticed from your suggestion...
$ VBoxHeadless -s "<MyVM>" -v off &
[1] 4516
Oracle VM VirtualBox Headless Interface 5.2.97
(C) 2008-2018 Oracle Corporation
All rights reserved.

$ VBoxManage controlvm "<MyVM>" addencpassword "<MyVM>" -
Enter password:
...I believe the '&' is meant to push that command to run in the background...? so that the command prompt comes back for your 2nd command - only that does not happen for me, no command prompt returns.

I've also noticed that if I start VM from command and then go to the GUI - its paused - I can save state and then restart the VM - but it then states in the GUI VM window; 'fatal error no boot medium' - but I'm guessing that is because no encryption password has been entered..?'

Anyway, I've tried your suggestion but I can't get as far as the 2nd command. If i try the 2nd command from a 2nd terminal, no luck either.


I've sorted it out now see next post, it was all about correct id as socratis suggested
Last edited by JW8888 on 14. Feb 2018, 00:24, edited 1 time in total.
JW8888
Posts: 9
Joined: 13. Feb 2018, 19:38

Re: Encrypted VM starting from command line

Post by JW8888 »

Hi socratis,

your suggestion about the 'id' I think has solved my problem
The only unclear part in the manual (for me at least) was that for the "id" part, I had to use the name of the VM, since I used the GUI and I didn't include specifically an ID. I guess it defaults to the VM name. I had to open the .vbox file to see the following:

<Property name="CRYPT/KeyId" value="MyVM"/>
I've chained my 2 commands together with the correct id now ( I had thought it was my user name ) and all is working..!

Thanks very much for your help!
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Encrypted VM starting from command line

Post by socratis »

And that's why you read the whole message before replying... ;)
Glad you got it going. Marking as [Solved].
I'll see what we can suggest as improvements to the documentation if needed...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply