Below is the bash script used to start and stop ss-agent
#!/bin/bash
## in .bash_profile
SSHAGENT=`which ssh-agent`
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
## in .logout
if [ ${SSH_AGENT_PID+1} == 1 ]; then
ssh-add -D
ssh-agent -k > /dev/null 2>&1
unset SSH_AGENT_PID
unset SSH_AUTH_SOCK
fi
Start and Stop ssh-agent
Rename Branch in github
Run below command change the branch name according to yours, Please pull before you run the below command
$ git branch -m old_branch new_branch
$ git push origin :old_branch
$ git push --set-upstream origin new_branch
Reverse Proxy for ssl (https)
Below is the VirtualHost conf example, Just change ServerName to yours And also change path of cert and key.
Check ssl module is enabled or not
<VirtualHost *:443>
ServerName example.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine on
SSLProxyEngine On
SSLCertificateFile path/to/example.crt
SSLCertificateKeyFile path/to/example.key
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:3026/
ProxyPassReverse / https://localhost:3026/
</VirtualHost>
Check ssl module is enabled or not
<VirtualHost *:443>
ServerName example.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine on
SSLProxyEngine On
SSLCertificateFile path/to/example.crt
SSLCertificateKeyFile path/to/example.key
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:3026/
ProxyPassReverse / https://localhost:3026/
</VirtualHost>
How to Install s3cmd in Linux and Manage Amazon s3 Buckets on ubuntu
On Ubuntu/Dabian:
$ sudo apt-get install s3cmd
Configure s3cmd Environment
# s3cmd --configureEnter new values or accept defaults in brackets with Enter. Refer to user manual for detailed description of all options. Access key and Secret key are your identifiers for Amazon S3
Access Key: xxxxxxxxxxxxxxxxxxxxxx
Secret Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Encryption password is used to protect your files from reading by unauthorized persons while in transfer to S3 Encryption
password: xxxxxxxxxx
Path to GPG program [/usr/bin/gpg]:
When using secure HTTPS protocol all communication with Amazon S3 servers is protected from 3rd party eavesdropping. This method is slower than plain HTTP and can't be used if you're behind a proxy Use HTTPS protocol [No]: Yes New settings:
Access Key: xxxxxxxxxxxxxxxxxxxxxx
Secret Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Encryption password: xxxxxxxxxx
Path to GPG program: /usr/bin/gpg Use HTTPS protocol: True
HTTP Proxy server name: HTTP Proxy server port: 0
Test access with supplied credentials? [Y/n] Y
Please wait, attempting to list all buckets... Success. Your access key and secret key worked fine :-) Now verifying that encryption works... Success. Encryption and decryption worked fine :-) Save settings? [y/N] y
Configuration saved to '/root/.s3cfg'
Importing and Exporting MongoDB Databases
Exporting from MongoDB
To export the database, simply tellmongodump which
database (or collection) you want to export, and where to export it to.
Mine was the pets database, so my command looks like this:mongodump -d pets -o petsbackup
|
pets database into the petsbackup directory. Take a look at what we have in that directory now:pets ├── animals.bson └── system.indexes.bson 0 directories, 2 filesThe only collection in my
pets database is the animals collection, however you'll see a .bson
file for each collection in your database, plus the system indexes
collection. It is up to you whether you want to take individual
collections, or a whole database, but bear in mind that your choice will
dictate whether you get information about indexes etc when you import
the data elsewhere.Importing to MongoDB
To import, simply use themongorestore command, which accepts either a single .bson file representing a collection, or a directory containing multiple files. Here's my example:mongorestore -d pets /path/to/pets
|
Migrate git from one server to another
Give new origin name here i have given as testtest and http://new-repo.com is new server repository url change as per yours .
-----------------------------------------------------------------------------------------------------------------------------------------
git clone --bare http://current-repo.com
-----------------------------------------------------------------------------------------------------------------------------------------
$git remote add testtest http://new-repo.com
-----------------------------------------------------------------------------------------------------------------------------------------
$git push -f --tags testtest refs/heads/*:refs/heads/*
-----------------------------------------------------------------------------------------------------------------------------------------
forever Upstart job for UBUNTU
Below is the upstart job for ubuntu for eg: create a file in /etc/init/test.conf and copy the below content to test.conf file, and change path to your app.js to yours,
#!upstart
description "node.js server"
author "kirthan shetty"
start on runlevel [2345] and started networking
stop on runlevel [!2345] or stopped networking
expect fork
script
export HOME="/root"
echo $$ > /var/run/yourprogram.pid
exec sudo -u root PORT=3004 /usr/bin/node /path to your app.js >> /var/log/yourprogram.sys.log 2>&1
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/yourprogram.sys.log
end script
pre-stop script
rm /var/run/yourprogram.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/yourprogram.sys.log
end script
to start #service test start
to stop # service test stop
#!upstart
description "node.js server"
author "kirthan shetty"
start on runlevel [2345] and started networking
stop on runlevel [!2345] or stopped networking
expect fork
script
export HOME="/root"
echo $$ > /var/run/yourprogram.pid
exec sudo -u root PORT=3004 /usr/bin/node /path to your app.js >> /var/log/yourprogram.sys.log 2>&1
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/yourprogram.sys.log
end script
pre-stop script
rm /var/run/yourprogram.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/yourprogram.sys.log
end script
to start #service test start
to stop # service test stop
Redirect url from non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.co [NC]
RewriteRule (.*) http://www.domain.co/$1 [L,R=301]
copy the above content to .htaccess file in your apache home directory
Change the domain to u'r domain name
RewriteCond %{HTTP_HOST} ^domain\.co [NC]
RewriteRule (.*) http://www.domain.co/$1 [L,R=301]
copy the above content to .htaccess file in your apache home directory
Change the domain to u'r domain name
How to Find and Kill a Process that is Using a Particular Port
I had a problem with tomcat, it says that port 8080 is already in use so I can not use it …
What I did ?
1- Find what application/process is using the pro, type:
You will get an output similar to this one
2- I have got the process Id, which is 1234, now this is the process that is using port 8080.
3- Kill the process, type:
----------------------------------------------------------------------------------------------------------------------------------------
kill 6782
What I did ?
1- Find what application/process is using the pro, type:
---------------------------------------------------------------------------------------------------- sudo netstat -lpn | grep :8080----------------------------------------------------------------------------------------------------You will get an output similar to this one
tcp6 0 0 :::8080 :::* LISTEN 6782/java2- I have got the process Id, which is 1234, now this is the process that is using port 8080.
3- Kill the process, type:
----------------------------------------------------------------------------------------------------------------------------------------
kill 6782
------------------------------------------------------------------------------------------------- How to Upgrade OpenSSL on UBUNTU
How to Upgrade OpenSSL on Ubuntu
This quick tutorial outlines how to upgrade openssl to the latest version on Ubuntu Server 13.04.
A
massive security hole has left over a third of the Internet's web
servers vulnerable to the "Heartbleed Bug" which was announced to the
public today. Use the following tool to check if your server is
vulnerable:You can run the following Bash script to upgrade your instance of OpenSSL to the latest version
--------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
###
# Need to upgrade an Ubuntu 13.04 server to use OpenSSL 1.0.1g?
# Read and execute this script :D
###
# License: WTFPL, GPLv3, MIT, whatever; just patch your shit
# http://askubuntu.com/questions/444702/how-to-patch-cve-2014-0160-in-openssl
###
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
wget https://www.openssl.org/source/openssl-1.0.1g.tar.gz
wget https://www.openssl.org/source/openssl-1.0.1g.tar.gz.asc
gpg --recv-key 0xD3577507FA40E9E2
# Dr Stephen Henson
# IMPORTANT! Manually verify that this is the correct key ID:
# http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0xD3577507FA40E9E2
# https://www.openssl.org/about/
gpg --verify openssl-1.0.1g.tar.gz.asc openssl-1.0.1g.tar.gz
if [[ $? -eq 0 ]]; then
tar xzvf openssl-1.0.1g.tar.gz
cd openssl-1.0.1g && sudo ./config && sudo make && sudo make install
# To link the old openssl library to a new version
sudo ln -sf /usr/local/ssl/bin/openssl `which openssl`
echo
echo "DONE!"
fi
# eof
------------------------------------------------------------------------------------------------
Wifi driver instalation ( Ubuntu )
Please try:
I believe cw-3.8 includes the modalias for your device.
If your device is still not shown, please post:
Please get a working ethernet connection, open a terminal and do:
Download this file to your desktop: https://www.kernel.org/pub/linux/kernel/projects/backports/2013/11/13/backports-20131113.tar.bz2 Right-click it and
select 'Extract Here.' Back to the terminal:
Reboot and let us know if it is working. You will have compiled the driver for your currently running kernel only. When Update Manager installs a newer kernel version, also known as linux-image, after you reboot, re-compile:
sudo apt-get install linux-backports-modules-cw-3.8-precise-generic
I believe cw-3.8 includes the modalias for your device.
If your device is still not shown, please post:
modinfo ath9k | grep 0036
dmesg | grep ath
Please get a working ethernet connection, open a terminal and do:
sudo apt-get install linux-headers-generic build-essential
Download this file to your desktop: https://www.kernel.org/pub/linux/kernel/projects/backports/2013/11/13/backports-20131113.tar.bz2 Right-click it and
select 'Extract Here.' Back to the terminal:
cd Desktop/backports-20131113/
make defconfig-ath9k
make
sudo make install
Reboot and let us know if it is working. You will have compiled the driver for your currently running kernel only. When Update Manager installs a newer kernel version, also known as linux-image, after you reboot, re-compile:
cd Desktop/backports-20131113/
make clean
make defconfig-ath9k
make
sudo make install
sudo modprobe ath9k
The requested URL /phpmyadmin/ was not found on this server. (phpmyadmin )
Not Found
The requested URL /phpmyadmin/ was not found on this server.
Apache/2.2.17 (Ubuntu) Server at localhost Port 80
Solution :
You will need to configure your apache2.conf to make phpMyAdmin works.
-----------------------------------------------------------------------------------------------------------------------------------------
sudo nano /etc/apache2/apache2.conf
-----------------------------------------------------------------------------------------------------------------------------------------Then add the following line to the end of the file.-----------------------------------------------------------------------------------------------------------------------------------------
Include /etc/phpmyadmin/apache.conf
-----------------------------------------------------------------------------------------------------------------------------------------
Restart the apache server :
-----------------------------------------------------------------------------------------------------------------------------------------
sudo service apache2 restart
-----------------------------------------------------------------------------------------------------------------------------------------
PPTP VPN Server on Debian/Ubuntu
PPTP VPN Server on Debian/Ubuntu
Quick setup: Copy and Paste
This section is for the impatient. All you have to do is login to your Debian/Ubuntu server and copy paste the following commands and you’ll have a working VPN server in less than 2 mins.In this section I assume you’re logged in as the root user, do NOT have any instance of pptpd installed now or earlier and the “net.ipv4.ip_forward” is commented in the /etc/sysctl.conf file.
apt-get install pptpd -yupdate-rc.d pptpd defaultsecho "localip 192.168.1.1" >>; /etc/pptpd.confecho "remoteip 192.168.1.2-254" >> /etc/pptpd.confecho "ms-dns 8.8.8.8" >> /etc/ppp/pptpd-optionsecho "ms-dns 8.8.4.4" >> /etc/ppp/pptpd-optionsecho "username * Pa55w0rd *" >> /etc/ppp/chap-secretsservice pptpd restartecho "net.ipv4.ip_forward=1" >> /etc/sysctl.confsysctl -piptables -I INPUT -p tcp --dport 1723 -m state --state NEW -j ACCEPTiptables -I INPUT -p gre -j ACCEPTiptables -t nat -I POSTROUTING -o eth0 -j MASQUERADEiptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -s 192.168.1.0/24 -j TCPMSS --clamp-mss-to-pmtuInstall the PPTPD package
On Debian/Ubuntu operating systemsapt-get install pptpd -yupdate-rc.d pptpd defaultsSetup VPN and DNS IP addresses
Edit the following filenano /etc/pptpd.confAnd add the following lines to the endlocalip 192.168.1.1remoteip 192.168.1.2-254You can use any private IP address range just make sure it is not
already used in your local network and the local IP and the remote IP
are in the same range.
Edit the following file to mention DNS servers
Add the following lines to the end
nano /etc/ppp/pptpd-options |
ms-dns 8.8.8.8ms-dns 8.8.4.4Add usernames and passwords
Edit the following filenano /etc/ppp/chap-secretsusername * password *Example
kirthan * rsEsss *user2 * vPnpass *If only you are going to use this VPN server a single username/password combination is enough.
Restart the pptpd service
service pptpd restartEnable forwarding and create iptables rules
Our main purpose of setting up this VPN server is to access website right ? So our traffic has to be forwarded out of the VPN server’s public network interface.Enable port forwarding on Linux by editing the sysctl.conf file
nano /etc/sysctl.conf |
Add or find and comment out the following line
net.ipv4.ip_forward=1 |
Save, close the file and run the following command to make the changes take effect.
sysctl -p |
The following iptables firewall rules allow port 1723, GRE and perform NAT
iptables -I INPUT -p tcp --dport 1723 -m state --state NEW -j ACCEPTiptables -I INPUT -p gre -j ACCEPTiptables -t nat -I POSTROUTING -o eth0 -j MASQUERADEIn the last rule replace “eth0″ with the interface connecting to the
internet on your VPN server. Finally the following rule is required to
ensure websites load properlyiptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -s 192.168.1.0/24 -j TCPMSS --clamp-mss-to-pmtuReplace 192.168.1.0/24 with the IP address range used in the “remoteip”
option in the /etc/pptpd.conf this firewall rule is used to ensure a
proper MTU value is used to prevent fragmentation. To save the IPTables
rules Create a VPN connection on your computer
Open the network setting and create new vpn connection
and add the Vpn server detai
and add the Vpn server detai
l like password username ip
Free OpenVPN and PPTP VPN
Click on this link : Free vpn server
SSL Authentication for website
Two Way SSL Authentication
In standard SSL connections your browser verifies the identity of the server via it's certificate. With 2 way authentication your browser also needs a certificate in order for the server to verify it and allow it access to the pages.Steps reqired :
|
Creating OpenSSL certificates
Make sure OpenSSL is installed on whichever server you want to be your CA.You will need an openssl.cnf file. Here is the one I used.
#/etc/ssl/openssl.cnf
[ req ]
default_md = sha512
distinguished_name = req_distinguished_name
[ req_distinguished_name ]
countryName = Country
countryName_default = GB
countryName_min = 2
countryName_max = 2
localityName = Locality
localityName_default = United Kingdom
organizationName = Organization
organizationName_default = SpiderWiki
commonName = Common Name
commonName_max = 64
[ certauth ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer:always
basicConstraints = CA:true
crlDistributionPoints = @crl
[ server ]
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
nsCertType = server
crlDistributionPoints = @crl
[ client ]
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment, dataEncipherment
extendedKeyUsage = clientAuth
nsCertType = client
crlDistributionPoints = @crl
[ crl ]
URI=http://www.spiderwiki.org/ca.crl
So first we need a self signed certificate for our CA.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
openssl req -config /etc/ssl/openssl.cnf -newkey rsa:2048 -nodes -keyform PEM -keyout ca.key -x509 -days 3650 -extensions certauth -outform PEM -out ca.cer-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Next we will generate a private SSL key for our server.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
openssl genrsa -out server.key 2048-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
To generate Certificate Signing Request (PKCS#10) run the following command. For the common name you should put the URL for the server e.g. www.spiderwiki.org
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
openssl req -config /etc/ssl/openssl.cnf -new -key server.key -out server.req-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
With self-signed certificate authority issue server certificate with serial number 100:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
openssl x509 -req -in server.req -CA ca.cer -CAkey ca.key -set_serial 100 -extfile /etc/ssl/openssl.cnf -extensions server -days 365 -outform PEM -out server.cer-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The new file contains both the certificate and the private key so we can delete the request file.
rm server.req
Now that the server certificates are done we need to create the key for a client.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- openssl genrsa -out client.key 2048
Then the request.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- openssl req -config /etc/ssl/openssl.cnf -new -key client.key -out client.req-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
And issue certificate ID with our CA for the client.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
openssl x509 -req -in client.req -CA ca.cer -CAkey ca.key -set_serial 101 -extfile /etc/ssl/openssl.cnf -extensions client -days 365 -outform PEM -out client.cer-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Save client's private key and certificate in a PKCS#12 format. You will need to set a password in this command.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
openssl pkcs12 -export -inkey client.key -in client.cer -out client.p12
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Then tidy up.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- rm client.key client.cer client.req-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Configure Apache
Depending on the version of Apache and your distro this can be slightly different so as a general guide.- You need to tell Apache to also listen on port 443 (at least that's the default for SSL)
- You need to enable the SSL module.
- Set a new VirtualHost (or modify your main server to use SSL)
- Move the required files to the location set in your virtual host.
- Restart Apache
#vi /etc/apache2/sites-available/default-ssl
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/securewww/
Options FollowSymLinks
Options Indexes FollowSymLinks MultiViews
LogLevel warn
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/ssl_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.cer
SSLCertificateKeyFile /etc/apache2/ssl/server.key
# Below for 2 way ssl
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile /etc/apache2/ssl/ca.cer
</VirtualHost>
</IfModule>
Configure your browser
Copy client.p12 file to the machine you intend to use. Install it into your browsers certificate store. This process is different on each browser.htaccess ip restriction
Create .htaccess file inside your site folder and copy the below content to .htaccess file and replace "your_site_folder" to your's and also the IP
----------------------------------------------------------------------------------------------------------------------------------------
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/vhosts/your_site_folder/.htpasswd #path to htpasswd
AuthGroupFile /dev/null
Satisfy Any
<Limit GET POST>
Order Deny,Allow
Deny from all
Allow from 192.168.0.5 #(ip needed to be allowed)
Allow from 192.168.0.6 #(ip needed to be allowed)
Allow from 192.168.0.7 #(ip needed to be allowed)
Require valid-user
</Limit>
----------------------------------------------------------------------------------------------------------------------------------------
The htpassd file can also be added in /etc/apache2/site-available ceare a file in this folder and add the below line to that folder. And below is that if you are using proxy.
<VirtualHost *:80>
ServerName kir.example.com
ProxyRequests off
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
AuthType Basic
AuthName "Please Log in"
AuthUserFile /var/www/myapp/.htpasswd #path to htpasswd file
Require valid-user
Order allow,deny
Allow from 000.00.00.00
Allow from 000.00.00.00
Allow from 000.00.00.00
satisfy any
ProxyPass http://localhost:3500/
ProxyPassReverse http://kir.example.com:3500/
</Location>
</VirtualHost>
----------------------------------------------------------------------------------------------------------------------------------------
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/vhosts/your_site_folder/.htpasswd #path to htpasswd
AuthGroupFile /dev/null
Satisfy Any
<Limit GET POST>
Order Deny,Allow
Deny from all
Allow from 192.168.0.5 #(ip needed to be allowed)
Allow from 192.168.0.6 #(ip needed to be allowed)
Allow from 192.168.0.7 #(ip needed to be allowed)
Require valid-user
</Limit>
----------------------------------------------------------------------------------------------------------------------------------------
OR
The htpassd file can also be added in /etc/apache2/site-available ceare a file in this folder and add the below line to that folder. And below is that if you are using proxy.
<VirtualHost *:80>
ServerName kir.example.com
ProxyRequests off
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
AuthType Basic
AuthName "Please Log in"
AuthUserFile /var/www/myapp/.htpasswd #path to htpasswd file
Require valid-user
Order allow,deny
Allow from 000.00.00.00
Allow from 000.00.00.00
Allow from 000.00.00.00
satisfy any
ProxyPass http://localhost:3500/
ProxyPassReverse http://kir.example.com:3500/
</Location>
</VirtualHost>
Add a User To Group Linux
Add a existing user to existing group :
To add an existing user jerry to sftpjail supplementary/secondary group with
usermod command using -a option ~ i.e. add the user to the supplemental
group(s). Use only with -G option:
-----------------------------------------------------------------------------------------------------------------------------
usermod -a -G sftpjail jerry
-----------------------------------------------------------------------------------------
To change existing jerry's primary group to lll, enter:
-----------------------------------------------------------------------------------------
usermod -g lll jerry
-----------------------------------------------------------------------------------------
Errr 'mongo.js:L112 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112'
If you are running Ubuntu, then there is an issue with folder ownership.
Run these commands:
|
Backup (mysql dump) all your MySQL databases in separate files
The below is the bash script to take mysql dump seperately
-----------------------------------------------------------------------------------------------------------------------------------------
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/backup/$TIMESTAMP"
MYSQL_USER="backup"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="password"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p $BACKUP_DIR
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/mysql/$db.gz"
done
-----------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/backup/$TIMESTAMP"
MYSQL_USER="backup"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="password"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p $BACKUP_DIR
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/mysql/$db.gz"
done
-----------------------------------------------------------------------------------------------------------------------------------------
HOW TO CREATE SSL SELF SIGNED CERTIFICATE ( UBUNTU )
About SSL Certificates
A SSL certificate is a way to encrypt a site's information and create a more secure connection. Additionally, the certificate can show the virtual private server's identification information to site visitors. Certificate Authorities can issue SSL certificates that verify the server's details while a self-signed certificate has no 3rd party corroboration.Set Up
Additionally, you need to have apache already installed and running on your virtual server.If this is not the case, you can download it with this command:
sudo apt-get install apache2
Step One—Activate the SSL Module
The next step is to enable SSL on the droplet.
sudo a2enmod ssl
Follow up by restarting Apache.
sudo service apache2 restart
Step Two—Create a New Directory
We need to create a new directory where we will store the server key and certificate
sudo mkdir /etc/apache2/ssl
Step Three—Create a Self Signed SSL Certificate
When we request a new certificate, we can specify how long the certificate should remain valid by changing the 365 to the number of days we prefer. As it stands this certificate will expire after one year.
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
With this command, we will be both creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.
This command will prompt terminal to display a lists of fields that need to be filled in.
The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your site's IP address.
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:New York Locality Name (eg, city) []:NYC Organization Name (eg, company) [Internet Widgits Pty Ltd]:Awesome Inc Organizational Unit Name (eg, section) []:Dept of Merriment Common Name (e.g. server FQDN or YOUR name) []:example.com Email Address []:webmaster@awesomeinc.com
Step Four—Set Up the Certificate
Now we have all of the required components of the finished certificate.The next thing to do is to set up the virtual hosts to display the new certificate.
Open up the SSL config file:
sudo nano /etc/apache2/sites-available/default
You should make the following changes.
Change the port on the virtual host to 443, the default SSL port:
<VirtualHost *:443>Add a line with your server name right below the Server Admin email:
ServerName example.com:443
Replace example.com with your DNS approved domain name or server IP address (it should be the same as the common name on the certificate).
Add in the following three lines to the end of your virtual host configuration, and make sure that they match the extensions below:
SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.keySave and Exit out of the file.
Step Five—Activate the New Virtual Host
Before the website that will come on the 443 port can be activated, we need to enable that Virtual Host:
sudo a2ensite default
You are all set. Restarting your Apache server will reload it with all of your changes in place.
sudo service apache2 reload
In your browser, type https://youraddress, and you will be able to see the new certificate.
INITIAL BEANSTALK GIT COMMIT TO MASTER BRANCH
Getting Started with Git & Creating your Repository
After you have installed Git, you need to setup the repository in your account and generate an SSH key.yum install git-core (this is for
centos)
apt-get install git-core (this is for ubuntu )Once installed, we recommend initializing Git. run the following commands.
git config --global user.name "kirthan"
git
config --global user.email "kirthan@example.com"Use your full name and email address, and by this you will setup Git for your purposes. You need to do this only once, the first time you install Git.
Start using Git
There are many different ways to use your Git repository. Since Git is very flexible you can start using your repository easily by importing, cloning, and many other ways.We will show you couple of common ways to start using your Git repository.
Starting from scratch
To start using your repository from scratch, in your command line type the following:mkdir my-project
cd my-project
git
init
echo "This is my new project on Beanstalk." >
README
git add README
git commit -m "My first commit."
git
remote add beanstalk
https://example.git.beanstalkapp.com/my-project.git
git push
beanstalk masterWith the commands above, you will create a folder, add a file to it, make your first commit, and push the changes to your repository, to master branch. Master branch is the default branch to use for your files.
Import existing files on your computer
To import your existing files from your local machine type the following in your command line:cd my-project
git init
git remote add
beanstalk https://example.git.beanstalkapp.com/my-project.git
git
add .
git commit -m "Importing my project to Git, without
saving history."
git push beanstalk master
Subscribe to:
Posts (Atom)
Start and Stop ssh-agent
Below is the bash script used to start and stop ss-agent #!/bin/bash ## in .bash_profile SSHAGENT=`which ssh-agent` SSHAGENTARGS="...
-
How to Upgrade OpenSSL on Ubuntu This quick tutorial outlines how to upgrade openssl to the latest version on Ubuntu Server 13.04. A m...
-
1 ) To check if your ext4 filesystem has the proper default options, use tune2fs as below : -------------------------------------------...