Use SSH with Textpad to execute commands on a remote server

Instructional HowTos, posted by users. No questions here please.

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
husby_d
Posts: 5
Joined: Mon Nov 27, 2006 10:18 pm

Use SSH with Textpad to execute commands on a remote server

Post by husby_d »

Using SSH with Textpad to execute commands on a remote server.

In my setup, I work on a large code base that sits on a Linux server farm.
I can edit the files in Textpad from my Laptop by network filesystem mounts (Samba). However to run the toolchains (compilers, etc.) I would normally need to log into the Farm via VNC and run commands there.

Using SSH, I can issue commands directly from Textpad, including compiles, version control (perforce), and other tools related to chip design.

Here's how to set it up:
1) Install the openSSH client. There are 2 ways to do this:

1a) Get a standalone package from http://www.mls-software.com/opensshd.html
You only need to install the client. Not the server.
Offer a token of gratitude to the owner for providing this, because the
alternative is:

1b) Install Cygwin with openssh. Over 1 gig of stuff that you probably don't need.

Notes:
Putty has a very good SSH client (plink), but for some reason can't
provide its output on STDOUT in a way that can be used by TextPad.

There are rumors that Windows will soon support a native SSH as part of
its power shell.

2) Setup a key pair between your PC and Server. You need this to
allow you to execute commands without typing a password every time.

2a) Open a Windows command shell and cd to your .ssh directory, and
run the keygen tool:

Code: Select all

    > cd C:\users\my_windows_name\.ssh
    > ssh-keygen
Use the defaults (or RTFM for advanced options).
Do not set a passphrase.
This creates a private key (id_rsa) and a public key (id_rsa.pub)

2b) Copy the text from id_rsa.pub to your authorized_keys file on your Farm login.
Do this from textpad by editing both files and pasting the text from one to the other.
Alternatively, copy the public key to the farm machine and the login to the Farm
machine.
The file is typically $HOME/.ssh/authorized_keys
(Note $HOME is your login directory)
If you don't find the file, create it, but make sure to set
permissions (chmod) to 700 for the .ssh directory, and 600 for
the file.

3) Optional - create a config file in C:\users\my_windows_name\config
This creates an alias name for the server. It allows you to have
a known name to use in Textpad tools. If the actual server name
changes, you only need to update the config file, and not all of
your textpad tool definitions. It should look like this:

Code: Select all

    Host tpad_server
      hostname farm_server_node_92
4) Add Tool commands to Textpad.
In Textpad 8, I found that I need to add the commands as DOS commands.
If you add it as a Program, then it opens a separate window to execute
the command, and doesn't use TextPad's "Tool Output" window.

An example command:
ssh tpad_server perforce_wrapper.pl P4OPEN $UNIXFile

This executes perforce_wrapper.pl on the Farm machine.

5) Take the extra effort to add output capture regular expressions
to the tool. It's amazing how useful it can be to click on an
error message and have Textpad take you to the source code.

6) Extra credit
Having set up all of this, you can now add the same SSH commands
to your windows context menus. You can execute some commands
without even opening textpad.
Post Reply