argordmel / ssh-bot

Messenger chat bot to access your server via SSH

Home Page:https://fb-ssh-bot.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ssh-bot

23550603_834202376757247_4960199550523408384_n

This is not a common Bot, is not going to respond you to a hello or give you the weather... This Bot is for the Ninja Developer, the one that can solve problems with his utility belt. This Bot is the utility belt he need.

Description

This is the source-code for a Facebook Messenger Chat Bot that is going to allow you to connect through SSH into your server.

This is what we support:

  • PEM connections (YES, you can use your Private Key)
  • Password Connections
  • String responses - The result of a command thrown
  • Image responses - The result of a command on a image, like you are seeing the Terminal!

Developers Circles

This project was made for the Community Challenge of Facebook Developers Circles.

We tried to construct an application that can make the coders more productive helping them to access servers, logs, restart applications, checking services status and SHARE outputs right on the palm of their hand (Mobile Devices).

How-it-works (Messenger)

These are the available commands you can use with our utility belt bot:

  • ssh -> Connect to your server
  • cmd -> Send commands
  • reconnect -> Connect to previous ssh connection
  • disconnect -> Close connection
  • help -> Show all the commands

Usage

Next, we are going to explain all the commands on more detail

ssh

You can use this command to connect to your server. We support the next arguments:

  • host
  • user
  • password
  • port: Default 22
  • pem: Just add it, no values

If you want to start a connection with a server with a password

ssh --host 127.0.0.1 --user root --password root

If you want to use a PEM, you need to send it to use first. Don't worry!, your information is secure:

screen shot 2017-11-16 at 16 55 55

When you receive the acknowledge text, you are able to connect using the PEM file

ssh --host 127.0.0.1 --user root --pem

cmd

This command would allow you to send commands (of course) to your server.

Remember, this is not an interactive console. You are not going to have good responses if you send a --tail command"

We support the next arguments:

  • --image: Just add it, no values
  • --interactive: Just add it, no values

Example:

cmd pwd

screen shot 2017-11-16 at 17 02 06

--image

Yes!, you here right. If you send the --image parameter you will recive the ouput on an image like your are seeing the terminal:

Example:

cmd ls -la

screen shot 2017-11-16 at 17 24 26

Yes, you can click and ZOOM IN

--interactive

Lots of Linux servers if you are not running interactive, the .bashrc file will exit early. So? If that happends, there are many commands that you are going to lose. So, if you send --interactive, your command is going to work like a charm

Example:

cmd npm --version --interactive

screen shot 2017-11-16 at 17 26 31

reconnect

If you already login, you dont need to send the command of ssh again. You can just reconnect

reconnect

disconnect

Just type disconnect to close your open connection

disconenct

help

If you need help with the commands, you can just type help

help

Technical Spoilers

Just read the code, don't be lazy. Just kidding. This application was done using NodeJS. This are the main packages that we are using:

To upload the attachments we are manually doing the request.

Install

Dependency (Node Canvas)

To convert String Text to Images we are using node-canvas. Said that, you need to have cairo C++ package. To install it:

OS Command
OS X brew install pkg-config cairo pango libpng jpeg giflib
Ubuntu sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
Fedora sudo yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel giflib-devel
Solaris pkgin install cairo pango pkg-config xproto renderproto kbproto xextproto
Windows Instructions on our wiki

El Capitan users: If you have recently updated to El Capitan and are experiencing trouble when compiling, run the following command: xcode-select --install. Read more about the problem on Stack Overflow.

Application

Then, comes the easy thing:

npm install

Done! Easy...

Start (Production)

npm start

Start (Development)

If you start the application this way, you are not going to be posting messages on Facebook

npm start-dev

Deployment

This application is currently deployed on a Heroku. It has the buildpacks already configured.

If you want to deploy it, you just need to execute:

heroku create <NAME>

You can find it currently here:

https://fb-ssh-bot.herokuapp.com/

License

Released under the terms of the MIT license.

About

About

Messenger chat bot to access your server via SSH

https://fb-ssh-bot.herokuapp.com/


Languages

Language:JavaScript 91.9%Language:HTML 8.1%