Skip to content

Messenger chat bot to access your server via SSH

Notifications You must be signed in to change notification settings

arielfr/ssh-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Facebook Hackaton Winner 2017

This project won the Facebook "Developer Circles Community Challenge" - Hackaton - on December 2017. Thank you for all the support.

Facebook Hackaton Post

screen shot 2018-01-02 at 12 47 54

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 Now. It has the now.json already configured.

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

now --docker --public

You can find it currently here:

https://ssh-bot.now.sh/

License

Released under the terms of the MIT license.

About

About

Messenger chat bot to access your server via SSH

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published