Skip to content

Latest commit

 

History

History
executable file
·
87 lines (63 loc) · 3.02 KB

DigitalOcean.md

File metadata and controls

executable file
·
87 lines (63 loc) · 3.02 KB

Getting Started with Digital Ocean

Start Here

Digital Ocean

  1. Create a Droplet
  2. Follow this or this tutorial to set up nodejs
  3. Follow this tutorial to install mongodb
  4. git clone this repo
npm install
sudo npm install pm2 -g
pm2 start server/index.js
pm2 startup ubuntu
sudo env PATH=$PATH:/usr/local/bin pm2 startup ubuntu -u sammy
  1. Create a Droplet on your Digital Ocean dashboard. Eg:
  • Droplet hostname: Example
  • Size: 5/mo
  • Droplet region:
  • Select image: Ubuntu 14.04 x64
  • Add your SSH key. Read more here
  • Remember to add Private Networking, it will be used later if you follow this node.js guide later on
  1. If you wish to secure your droplet even further, read on:

a. ssh into your server as root

b. Create a new user:

It's actually not a good idea to ssh in as root on a regular basis, because of how much power root has. It makes it easy to make destructive change, even by accident!

# adduser demo

c. Give root privelleges to the new user account. gpasswd -a demo sudo

So if you need to run a command with root privelleges, type sudo <command> d. Add public key authentication

* Manually install the public key. Copy your public key

* Switch from `root` to your new user. `su - demo`

* Make a directory and restrict its permissions:

  ```
    mkdir .ssh
    chmod 700 .ssh
  ```

* `vim .ssh/authorized_keys`

* `chmod 600 .ssh/authorized_keys`

* `exit` to return to `root` user

* Configure the ssh daemon:
`vim /etc/ssh/sshd_config`
Edit `PermitRootLogin yes` to become `PermitRootLogin no`

* Reload your ssh `service ssh restart`

READ more in Reference 2 and 3

FAQ

  1. ssh root@<ip-address> still prompts me for my password, even when I have entered my ssh prior to this!

You can try editing your ~/.ssh/config file to have this additional entry:

Host digitalocean
  HostName <Digital Ocean IP Address>
  User <user>
  IdentityFile ~/.ssh/<rsa_key_name>

The next time you can just ssh digitalocean and you're in!

Reference

  1. How to connect to your droplet with SSH
  2. How to use ssh keys with droplets
  3. Initial Server setup with Ubuntu 14.04