Running SSH Commands in PhpStorm

I can see two places that seem to make it possible to do something like this.

1. Command Line Tools, if configured, it seems to be possible to connect to SSH and run commands (but I could be mistaken)

2. Under Tools menu, there's a Run Command option

Has anyone tried using either of the above methods to connect to SSH and run commands? I have a deployment script I want to run as soon as I'm done uploading, which is basically running a PHP script (inaccessible via web). I can keep Terminal up (on a Mac) I guess, but it would be cool to just do it all from within the IDE. I'm aware there's a vote up for an internal SSH client, but didn't know if anyone had dealt with workarounds yet.

Thanks in advance!

2 comments
Comment actions Permalink

Hi Scott,

As far as I'm aware #1 and #2 are the same (#2 will open Command Line Tools Console where you can type those commands).

I'm not using SSH myself (have not dealt with it for a long time, and even then it was all manual typing commands), but you can create some batch/bash script that will do all the job (connect to server, execute remote commands etc) and then call it from PhpStorm using External Tools functionality (Settings | External Tools). If you are using Phing tasks in your deployment/build process, you can call such script from there as well (as separate task or part of another task).

0
Comment actions Permalink

Aha! That did it!

For others' enjoyment, the process I went through was:

  1. Created a simple bash xxxxx.sh script, saved it to a folder on my comp (mine does a SSH connect, utilizing a RSA key already saved on my system, and runs some commands on the server - with parameter hooks for PhpStorm to pass)
  2. Go to PhpStorm > Settings > External Tools > Add...
  3. Give your tool a name, maybe a group if it's handy for you to keep organized
  4. I chose to keep the checkboxes here all as they were, except for Open Console (don't need to see it) and Menu > Search Results since I don't need it displayed there
  5. Program: bash
  6. Parameters: mybashscript.sh $Prompt$ (you can actually put parameters here as you want, like mybashscript.sh param1 param2 etc)
  7. Working directory: Just browse to the folder your bash script is in and select
  8. Click OK


Optional - Set Keymap:

  1. Go to PhpStorm > Settings > Keymap, and expand 'External Tools'
  2. Select the tool you added, and attach a keymap


Figuring all of this out has been awesome, I now see visions of crazy scripts and time saving stuff going on in my near future! Thanks for the pointer, I absolutely couldn't have figured this out without you saying this should be an External Tool!

0

Please sign in to leave a comment.