I copied that public key and went to Laravel Forge’s Account Settings > SSH Keys and pasted it in. Then, I clicked the button to have this SSH key uploaded to my servers.
What this allows you to do is to run ssh forge@<your_server_ip> from your computer’s terminal, and to be authorized to log into your server. This also enables you to connect to the database that’s on your server.
To see your Forge-created database in TablePlus, open your server in Forge’s appp and click Database in the sidebar. Then, copy the Database Connection URL they provide, and paste it in a new tab.
When you visit that URL, it’ll ask if you want to open TablePlus. Allow it to open TablePlus.
TablePlus will first ask you for your SSH password, which you might have set up when you created the SSH key on your laptop (or left blank for no password). Enter that in.
Then TablePlus will tell you access denied. That’s fine though! We have the credentials to access the server (through the SSH key), but not the password to access the database within the server.
Click “edit connection” in the TablePlus popup, and find the email that Forge sent you when your server was first created (subject: “Forge: server (Your Server Name) provisioned”). That email contains your Database Password at the bottom. Paste that password into the upper Password field in TablePlus:
Try testing the connection (hopefully everything will go green to indicate that the credentials work), and save it.
If testing the connection didn’t work because the SSH key doesn’t seem to be working, you might have to click Import a private key at the bottom of the edit screen and manually point TablePlus towards your secret ~/.ssh/id_rsa file.
Now, you have the Forge database set up in TablePlus! You can use TablePlus on your computer to view and edit your production database remotely.
Subscribe to my newsletter!
A weekly round-up of new blog posts and updates to projects I’m working on.