Git Product home page Git Product logo

whatsupp-ssh's Introduction

Whatsupp SSH? Node badge LICENSE

node+twilio+ec2

This is a Nodejs application integrated with Twilio's API for WhatsApp, which could be installed and configured on any remote server(dead simple to setup!, trust me ๐Ÿ™Œ) or computer(with UNIX based OS), results in gaining access to it remotely and execute shell commands over WhatsApp.

๐Ÿ“Œ Click on DEV logo below to view detailed post

Manoj Naidu's DEV Profile

How to Setup?

The setup process is really simple, you just have to follow these four steps...

๐ŸŸข STEP-1. Signup for a Twilio Account and join the Twilio Whatsapp sandbox.

  • Signup for an account here

Alt Text

  • Now, login and join the sandbox by doing as directed on screen and complete all 3 steps. Don't share your sandbox code with anyone (The red block covers my sandbox code)

Alt Text

  • One final thing needs to be added into twilio. We will see that later...

๐ŸŸข STEP-2 Configure port on the server/ computer.

  • If you are setting up in the local computer, then you are free to skip to STEP-3.

  • If setting up in a remote server, then you need to configure the instance/ droplet to open port 3003 for incoming requests.

๐Ÿ“Œ port 3003 is where Twilio would be forwarding the requests to...

If using AWS EC2 then you need to add a new rule inside Security Groups -> Inbound rules of a particular instance.

Alt Text

  • Then add a new rule like so...

Alt Text

๐Ÿ“Œ If using other than EC2, then refer to official docs.


๐ŸŸข STEP-3 Let's move towards our computer/ server.

๐Ÿ“Œ All the actions from now are performed inside the terminal.

  • cd into the directory where you want to clone the app.

  • Now, clone this repo.

$ sudo git clone https://github.com/manojnaidu619/Whatsupp-SSH.git
  • cd into the project folder and run sudo npm install
$ cd Whatsupp-SSH/ 

$ sudo npm install
  • As we are logging the requests into a log file, we need to give appropriate permissions to the app directory and the folders inside it. (The path to project must be absolute)
$ sudo chmod -R a+rw ~/home/Whatsupp-SSH
  • Now adding env variables, which our app relies on. Make sure the key is same as mentioned below.

๐Ÿ“Œ Here, I am considering Ubuntu as the OS.

$ sudo nano /etc/bash.bashrc

scroll down to the bottom of the file and add these lines by replacing the values.

export SSH_PSWD=YOUR_DESIRED_PASSWORD
export TWILIO_URL=http://PUBLIC_IP_OF_SERVER:3003/Whatsupp-SSH
export TWILIO_AUTH_TOKEN=YOUR_TWILIO_AUTH_TOKEN

then source the bash.bashrc file by typing.

$ source /etc/bash.bashrc
  • Now, copy the same TWILIO_URL that was added to bash.bashrc file.

๐Ÿ“Œ Remember that we had one last thing to add to Twilio sandbox configuration... It's time to do that.

head to twilio console -> programmable SMS -> Whatsapp -> Sandbox

Alt Text

After adding that, scroll down and hit Save.


๐ŸŸข STEP-4. Head to your server/computer and run these final commands.

  • install pm2.
$ sudo npm install pm2 --global
  • Now, run pm2 startup to initialize startup scripts. So, whenever the server reboots/ crashes, our node app would also be picked up automatically.
$ pm2 startup

Alt Text

Now copy-paste the command given by pm2 (the one outlined by red border) and hit enter.

  • Now, to save them all run pm2 save.
$ pm2 save
  • just one final command left, you have successfully setup the app. Now let's start the pm2 server.
$ pm2 start ABSOLUTE_PATH_TO_WHATSUPP-SSH/src/app.js

Alt Text

Hurray! ๐Ÿ™Œ your app is now up and running, get started by sending a simple command to your Twilio sandbox over Whatsapp.

๐Ÿ“Œ For more info on unique features, security, limitations... check out the complete post by clicking on the DEV logo.

Manoj Naidu's DEV Profile

License & copyright

ยฉ 2020 Manoj Naidu

Licensed under MIT License

whatsupp-ssh's People

Contributors

manojnaidu619 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.