Create Ubuntu Droplet at Digital Ocean
by John Vincent
Posted on August 9, 2018
This is part of a series of discussions regarding Deploying to a Digital Ocean Droplet. For more details, please see Overview of johnvincent.io website
Create Ubuntu Droplet at Digital Ocean
- Create Droplet
Ubuntu 16.04 x64- Standard: $5/month
- Choose a datacenter region
- No SSH key
- Hostname: website (name that makes sense)
The Ubuntu droplet is created and an IP provided.
Set Root Password
Dashboard
- Select droplet
- Access (left nav)
- Reset Root Password
- Password is emailed.
Get password from your email.
Launch Console
root
- {password-from-your-email}
Change password
How To Connect To Your Droplet with SSH
- Connect to droplet
- ssh root@{your-ip}
The authenticity of host '<your-ip> (<your-ip>)' can't be established.
Are you sure you want to continue connecting (yes/no)?- Yes
Basic configuration
Add user
adduser {remote-user}- {password}
Root privileges
usermod -aG sudo {remote-user}
Add Public Key Authentication
From Mac
cd .ssh
ssh-keygenEnter file in which to save the key (/Users/<my-user>/.ssh/id_rsa): id_digital_ocean- passphrase: do not provide a passphrase
Generates two files
- private:
id_digital_ocean - public:
id_digital_ocean.pub
Store key in keychain
chmod 600 id_digital_ocean*
ssh-add -K id_digital_oceanAdd to .ssh/config
Host mywebsite
UseKeychain yes
AddKeysToAgent yes
HostName <your-ip>
User <your-user>
IdentityFile ~/.ssh/id_digital_oceanCopy public key to remote server
cd
cd .ssh
ssh-copy-id <remote-user>@<your-ip>Verify Public Key on Remote Server
- Login to digital ocean droplet
su - <remote-user>- cd .ssh
- view
authorized_keys- Key should be present
Disable Password Authentication
As root or your sudo user, open the SSH daemon configuration
sudo vi /etc/ssh/sshd_configset:
PasswordAuthentication noensure:
PubkeyAuthentication yes
ChallengeResponseAuthentication noreload the SSH daemon:
sudo systemctl reload sshdTest Log In
ssh <remote-user>@<your-ip>should log in without any passwords.
Set Up a Basic Firewall
List applications:
sudo ufw app listAvailable applications: OpenSSH
Ensure firewall allows SSH connection:
sudo ufw allow OpenSSHenable the firewall:
sudo ufw enableYou can see that SSH connections are still allowed by typing:
sudo ufw statusAdd Swap
Check System for Swap
sudo swapon -sCheck current disk usage
df -hCreate Swap File
sudo dd if=/dev/zero of=/swapfile bs=1G count=4if this fails with:
dd: memory exhausted by input buffer of size 1073741824 bytes (1.0 GiB)then try:
sudo fallocate -l 4G /swapfileCheck swap file
ls -lh /swapfileEnabling the Swap File
Secure the swap file:
sudo chmod 600 /swapfiletell our system to set up the swap space:
sudo mkswap /swapfileenable the swap:
sudo swapon /swapfileverify:
sudo swapon -sMake the Swap File Permanent
Edit configuration file:
sudo vi /etc/fstabAdd to the end:
/swapfile none swap sw 0 0Tweak your Swap Settings
Current swappiness value by typing:
cat /proc/sys/vm/swappinessFor a VPS system, this number needs to be close to zero.
Edit configuration:
sudo vi /etc/sysctl.confAt the bottom, add:
vm.swappiness=10Another related value that you might want to modify is the vfs_cache_pressure. This setting configures how much the system will choose to cache inode and dentry information over other data.
cat /proc/sys/vm/vfs_cache_pressure
sudo vi /etc/sysctl.conf
add:
vm.vfs_cache_pressure = 50Check Swap
sudo swapon --summary
free -hInstall Basics
sudo apt-get update
sudo apt-get install zip wgetInstall Node and Npm
Node V6 - Best for Production
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejswhich node
/usr/bin/node
which npm
/usr/bin/npm
node -v
v6.11.1
npm -v
v3.10.10Node V4 - Reference Purposes Only
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npmnodejs -v
v4.2.6
npm -v
3.5.2Uninstall
which node
which npmsudo apt-get remove nodejs
sudo apt-get remove npmcd /etc/apt/sources.list.dand remove any node list.
sudo apt-get updateDigital Ocean
- Building and deploying MyTunes to johnvincent.io
- Building and deploying React Github Helper App to johnvincent.io
- Configuring Google Domains
- Create Ubuntu Droplet at Digital Ocean
- Create Ubuntu Droplet at Digital Ocean
- Deploy Feediator to Digital Ocean
- Deploy to Droplet
- Feediator Overview
- Feediator Project
- Maintaining Ubuntu Droplet
- Maintaining Ubuntu Droplet
- Overview of Deployment of a Node API Server
- Overview of johnvincent.io
- Overview of johnvincent.io Jekyll website
- Overview of React Gomoku
- Overview of React Hangman
- Overview of React Lights Out
- Overview of React Yahtzee
- TaskMuncher Overview
Johnvincent.io
- Backup Website from Digital Ocean
- Building and deploying MyTunes to johnvincent.io
- Building and deploying React Github Helper App to johnvincent.io
- Configure HTTP Nginx
- Configure HTTPS Nginx
- Configure PM2
- Configuring Google Domains
- Create SSL Certificates
- Create Ubuntu Droplet at Digital Ocean
- Deploy to Droplet
- Google Webmaster Tools
- Install Ubuntu Nginx
- Maintaining Ubuntu Droplet
- Overview of Deployment of a Node API Server
- Overview of johnvincent.io
- Overview of React Gomoku
- Overview of React Hangman
- Overview of React Lights Out
- Overview of React Yahtzee
- Restricting Access with HTTP Basic Authentication
- Update SSL Certificates
Ubuntu
- Configure HTTP Nginx
- Configure HTTP Nginx
- Configure HTTPS Nginx
- Configure HTTPS Nginx
- Configure PM2
- Create SSL Certificates
- Create SSL Certificates
- Create Ubuntu Droplet at Digital Ocean
- Create Ubuntu Droplet at Digital Ocean
- Deploy Feediator to Digital Ocean
- Install Jekyll Ubuntu
- Install Ubuntu Mongo
- Install Ubuntu Nginx
- Install Ubuntu Nginx
- Maintaining Ubuntu Droplet
- Maintaining Ubuntu Droplet
- SSH to Github
- Update SSL Certificates
- Update SSL Certificates