Rainieren
1 year ago

SSH into server using server-IP and run commands

Posted 1 year ago by Rainieren

Hello, I've been trying to get something done for a long while now with no success, I'm trying to SSH into a server using an IP of a server that was created and run commands on that specific server.

I have a system where droplets(servers) get created. After a while, I receive the IP of this server and I somehow need to manage to connect to these servers and run commands. My try was to do something like this

$droplet = Droplet::where("webshop_id", "=", $id)->get();

        \SSH::into($droplet->ip)->run([
           'cd var/home',
        ]);

But that doesn't work. How can I make this work? I've looked on https://laravelcollective.com/docs/5.4/ssh but I can't find my solution there.

The IP varies per created server so using remote.php is not an option except if it can be changed dynamically

Please sign in or create an account to participate in this conversation.