I want to develop locally using Laravel Homestead, but Laravel should be connected to a remote DB via SSH Tunnel, not the Homestead one.
Somehow I cannot find out how to do so. Is it even possible?
This is not a Laravel problem, this an operating system one. You can setup your Tunnel:
ssh -L 3307:ec2-172-16-139-19.us-west-1.compute.amazonaws.com:3306 deploy@ec2-174-129-17-196.compute-1.amazonaws.com
Where
3307 is the local port,
ec2-172-16-139-19.us-west-1.compute.amazonaws.com is the database host,
3306 is the listening port,
deploy is the database username, and
ec2-174-129-17-196.compute-1.amazonaws.com is the remote host.
Then you just need to configure your Laravel connection to connect to
'mysql' => [
'host' => 'localhost',
'port' => 3307,
],
Open your config/database.php
and add find your mysql connection.