SuperGeekery: A blog probably of interest only to nerds by John F Morton.

A blog prob­a­bly of inter­est only to nerds by John F Mor­ton.

Reset the forge sudo password in Laravel Forge

Recipe new sudo pw

The narration of this post was created with Bespoken plugin for Craft CMS.

Have you misplaced the sudo password for your user and need to reset it?

In Laravel Forge, you can save reusable bash scripts in the control panel and run them as the root user. Save the following in a Recipe, updating NEW_SUDO_PASSWORD with your desired password each time. If you're resetting a user other than forge, update the user. Run it on your server. Presto! You've got your sudo password back. The same script also works if you have root SSH access through your provider, like Digital Ocean.

The bash script reads: echo. forge. colon. new sudo password. followed by a pipe symbol. and C. H. P. A. S. S. W. D.

echo "forge:NEW_SUDO_PASSWORD" | chpasswd