How to send the keys Alt+F9 to Microsoft Azure Serial Console for Linux?

Danny Beckett asked:

I need to gain root access to a newly-created VM hosted on Microsoft Azure. This is done on FreePBX (running CentOS) by sending the keys Alt+F9 on the console and issuing the command !passwd root.

How can I send modifier keys to Azure’s Serial Console?

My answer:

You don’t, because Alt+F9 is a keypress that only makes sense on the actual Linux framebuffer console. It switches to virtual terminal 9 on the real console. While it’s possible to view the virtual machine’s console using Boot Diagnostics, Azure doesn’t allow sending keystrokes to the console. Therefore it is not possible to perform that action.

If you want to change the root password, you need to either log in with your normal user and sudo, or mount the virtual disk to another VM and edit its password (shadow) file from there.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.