wget -qO ee rt.cx/ee && sudo bash ee
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
Move nvm source commands to the top in .bashrc
file. So that it works from deploy pipeline non-interactive shell.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install v8.1.4
npm install -g pm2@latest
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub
Copy the SSH key and add it to the deploy keys of the repository.
So that the server can pull latest changes while deploying.
Then run below command to save the imprint of Github server on production server.
ssh git@github.com -T
Import the public key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
Create a list file for MongoDB For Ubuntu 16.04
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Reload local package database
sudo apt-get update
Install the MongoDB packages
sudo apt-get install -y mongodb-org
Start MongoDB
sudo service mongod start
Run following command to start the mongo terminal.
mongo
Run following commands into the Mongo terminal.
use your_db
db.createUser({
user: 'your_username',
pwd: 'your_password',
roles: [{ role: 'readWrite', db:'your_db'}]
})
The above user will have read and write access for the given database.
Edit your MongoDB config file.
sudo vim /etc/mongod.conf
Look for the net
line and comment out the bindIp
line under it, which is currently limiting MongoDB connections to localhost
Warning: Do NOT comment out the bindIp
line without enabling authorization. Otherwise you will be opening up the whole internet to have full admin access to all mongo databases on your MongoDB server!
# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1 <- comment out this line
Scroll down to the #security:
section.
Add the following line. Make sure to un-comment the security:
line.
security:
authorization: 'enabled'
Save the file. And done!
Restart the mongodb service.
sudo service mongod restart
Now You should be able to connect to the MongoDB with the above username and password.
- Disable the security temoporarily in the MongoDB config file mentioned above.
- Comment out the security section.
- Save the file.
- Restart the mongodb service
sudo service mongod restart
- Add new user just like we did it earlier from the above commands.
- Remove old user with
db.removeUser('username')
- Or perform any other admin tasks.
- Enable the security again once you are done.
- Restart the mongodb service