Minimal SSH in Slack!
Every message you send to the channel will be interpreted as a one-off command. Super easy.
cd
doesn't work, so run cd dir/; my-command
to run a given command in the given directory.
Prefix any message with #
to not execute it (e.g. # what's up guys?
)
Requirements:
- Some sort of web host
- A server to SSH into, with SSH set up and configured
- An SSH key pair, with the public key installed on the server
First, create a Slack app. Subscribe to the message.channels
bot event, then create a bot token with the chat.write
scope.
Point your events to the <your app>/slack/events
endpoint.
SLACK_SIGNING_SECRET = your Slack app's signing secret
SLACK_BOT_TOKEN = the bot token
SLACK_CHANNEL = the ID of the channel you're running SSH in (the bot must be a member of this channel)
SSH_HOST = the IP of the server to SSH into, e.g. 123.456.78.90. Only port 22 is supported right now.
SSH_USER = login name of the user you're SSHing into
SSH_PRIVATE_KEY_PATH = absolute path to your SSH private key file. (NOT REQUIRED WHEN RUNNING IN DOCKER, SEE BELOW)
When running in Docker, pass your base64-encoded private key as a build arg named SSH_PRIVATE_KEY
. The SSH_PRIVATE_KEY_PATH
env variable is NOT required in this case.