Oracle Cloud Agent Commands is another useful feature recently launched on OCI.
This resource gives you the ability of remotely running scripts within the instance using the run command feature.
Let’s say you need to restart the sshd deamon to be able to login again.
Not a problem, just go to the console, hit create command and write a script to start it up again 🙂

After a few minutes you can check the output:


Return code was sucessfull but it actually failed with error below:
Failed to start sshd.service: Interactive authentication required. See system logs and 'systemctl status sshd.service' for details. Mon Dec 14 21:21:05 GMT 2020
For privileged commands to work you need to grant sudo privileges to ocarun user.
You can also check the logs at /var/log/oracle-cloud-agent/plugins/runcommand/runcommand.log file.
IAM policies are required for this feature to work so go ahead and read the documentation here.