Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jumpkick's avatar

Laravel SSH facade and Homestead

I'm working on a deployment script which will use Laravel's remote.php class to pull from Git, run migrations, etc. On production, this is all working. Using app/config/remote.php, I can successfully connect to the remote server and run something like the following in an Artisan command:

$commands[] = "php artisan migrate";
SSH::into('production')->run(
    $commands
);

The problem here is that I want to run this against my Homestead box in order to test before I do this on production (for obvious reasons!), but I can't seem to figure out what the local version of the connection should be.

'local' => array(
            'host'      => 'localhost:2222',
            'username'  => 'vagrant ',
            'password'  => ' ',
            'key'       => '',
            'keyphrase' => '',
            'root'      =>'/home/vagrant',
        ),

What is the correct configuration for this? I think it's restricting SSH to only use the RSA public key, but in order to test a deploy script I need to be able to connect using the SSH::into("local") code.

Any clues?

0 likes
2 replies
bashy's avatar

You want to SSH into VM via VM? Where's it connecting from / to?

jumpkick's avatar

Well, not exactly. The SSH facade allows you to write an Artisan command which I am calling "deploy"

php artisan deploy

Inside the fire() function, I have code which does the following.

  • Switch to the production branch in Git.
  • Merge my master branch into production.
  • Push production to Git.
  • SSH into the production server.
  • CD to the site folder.
  • Run php artisan down.
  • Pull from Git.
  • Run any migrations.
  • Run any composer updates.
  • Clear Laravel cache.
  • Run php artisan up.

I want to add some new features to this, but now that the production machine is live I want to be able to test new features against my Homestead box instead of the live one. So instead of the production credentials, I want to be able to connect, via the SSH facade, to the Homestead machine and watch the results.

Does that make sense?

Please or to participate in this conversation.