git for managing web public html directory


On GitServer [ ip:192.168.0.123 ]

useradd gituser1 -m -s /bin/bash

mkdir -p /project/ecommerceweb
chown -R gituser1:gituser1 /project


cd /project/ecommerceweb
git init --bare

Note:-To have separate worktree

vim /project/ecommerceweb/hooks/post-receive

#!/bin/bash
GIT_WORK_TREE=/webdir/web git checkout -f

#<save/exit>

chmod +x /project/ecommerceweb/hooks/post-receive



On git client [ ip:192.168.0.123 ]

#copy your ssh public key to git server for user "gituser1" for passwordless ssh and public/private key based authentication

ssh-copyid gituser1@192.168.0.239

git clone ssh://gituser1@192.168.0.239/project/ecommerceweb
cd ecommerceweb
vim index.php
... < add your code /save/exit> ..

git add . # add files to index
git commit -m "initial commit added index page" #Record changes to the repository
git push origin master #push changes to git server
git status

git remote show origin #shows your remote gitserver url OR use

git config --get remote.origin.url



View changed files in your working repository

## git status

Git log

show all git commits

## git log

Git diff

made changes to tracked files

## git diff

Git branch

list all branches

## git branch


ispconfig3 freshclam command error

ERROR: /var/log/clamav/freshclam.log is locked by another process
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).


had to ---> sudo /etc/init.d/clamav-freshclam stop

then sudo freshclam -v

and it worked for me.

then restart the daemon with

sudo /etc/init.d/clamav-freshclam start

after it was restarted i was able to run the freshclam -v command with no more porblems. thinking it might have been locked up..??

aws RDS for external mysql master

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Procedural.Importing.External.Repl.html

mysql error #1005 - Can't create table (errno: 150) importing database from another server

http://stackoverflow.com/questions/9018584/error-code-1005-cant-create-table-errno-150/30102503#30102503
Reference link to stackoverflow

This could also happen when exporting your database from one server to another and the tables are listed in alphabetical order by default.
So, your first table could have a foreign key of another table that is yet to be created. In such cases, disable foreign_key_checks and create the database.
Just add the following to your script:

vim export.sql

use  databasename100;
SET FOREIGN_KEY_CHECKS=0;
..
..
...sql'sss ....

and it shall work.



reset user password using GRUB and set grub password in the end Ubuntu 14.04 LTS

on boot menu

select  "e" to edit the menu item
find line starting with "linux..." and in the end append  init=/bin/bash
and press
ctrl+x

mount -o remount,rw /
passwd <username>
reboot -f

To set grub password

login as root

# grub2-mkpasswd-pbkdf2 
OR
grub-mkpasswd-pbkdf2

Password: ****
Reenter password: ****
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A

Paste the encrypted long string into the file /etc/grub.d/40_custom

eg. copy the content starting from "grub.pbkdf2.sha512.10000.9CA461100..."

vim /etc/grub.d/40_custom

set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A...

grub2-mkconfig -o /boot/grub2/grub.cfg
or 
grub-mkconfig -o /boot/grub2/grub.cfg

if on the local terminal use help of "tee"

grub-mkpasswd-pbkdf2 | tee myhelper.txt

your password content and other text are copied in myhelper.txt, edit this myhelper.txt file and cat its content to /etc/grub.d/40_custom

cat myhelper.txt >> /etc/grub.d/40_custom
grub-mkconfig -o /boot/grub2/grub.cfg

apache xss protection headers

Setting up Apache to emit NoSniff, X-Frame and X-XSS-Protection headers

Security Headers is a service which checks that your web server is not revealing too much information. It does this by checking the HTTP headers returned with every request. The service checks to see if the server information is being leaked or if it’s reporting what scripting language is being used in the X-Powered-By header.
The service also checks and reports on a list of useful security headers like NoSniff, which prevents browsers from MIME-sniffing a response away from the declared content-type. It also checks for headers which prevent clickjacking and cross site scripting by detecting if X-Frame-Options and X-XSS-Protection are defined.

Add the headers to the Apache config file

I decided it would useful to implement these headers on the web servers I support. In particular I wanted to prevent other sites from framing my content within an iframe. By setting the X-Frame-Options to deny I am explicitly disallowing framing of any type. After a little research, these are the headers that my servers now emit:
<IfModule mod_headers.c>
    Header unset ETag
    Header set X-Frame-Options: deny
    Header set X-XSS-Protection: "1; mode=block"
    Header set X-Content-Type-Options: nosniff
    Header set X-WebKit-CSP: "default-src 'self'"
    Header set X-Permitted-Cross-Domain-Policies: "master-only"
</IfModule>
If your using the Joomla CMS, then using deny on the X-XSS-Protection will prevent the media manager from working properly. In this case you will need to relax the setting to use the same origin policy:

Header set X-Frame-Options: sameorigin

ssh error

root@server1:~# service ssh restart
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
[....] Restarting OpenBSD Secure Shell server: sshdCould not load host key: /etc/ssh/ssh_host_ecdsa_key

The root cause of this problem is that sshd daemon somehow is not able to load SSH host keys.
When OpenSSH server is first installed on Linux system, SSH host keys should automatically be generated for subsequent use. If, however, key generation was not finished successfully, that can cause SSH login problems like this.
Let's check if SSH host keys are found where they should be.
$ ls -al /etc/ssh/ssh*key 
make sure size is not zero,
good example:-
 root@server1:~# ls -al /etc/ssh/ssh*key
-rw------- 1 root root  668 Nov 30 18:12 /etc/ssh/ssh_host_dsa_key
-rw------- 1 root root  227 Dec  5 15:03 /etc/ssh/ssh_host_ecdsa_key
-rw------- 1 root root 1675 Nov 30 18:12 /etc/ssh/ssh_host_key
-rw------- 1 root root 1671 Nov 30 18:12 /etc/ssh/ssh_host_rsa_key

[SOLUTION - debian / ubuntu ]
root@server1:~# dpkg-reconfigure openssh-server
Creating SSH2 ECDSA key; this may take some time ...
[ ok ] Restarting OpenBSD Secure Shell server: sshd.

[SOLUTION - redhat/centos]
On CentOS, RHEL or Fedora, all you have to do is to restart sshd after removing existing (problematic) keys.
$ sudo rm -r /etc/ssh/ssh*key

$ sudo systemctl restart sshd

An alternative way to regenerate SSH host keys is to manually generate them using ssh-keygen command.
$ sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
$ sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
$ sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key 
Once new SSH host keys are generated, make sure that they are found in /etc/ssh directory. There is no need to restart sshd at this point.
$ ls -al /etc/ssh/ssh*key
Now try to SSH again to the SSH server to see if the problem is gone.

ispconfig 3 phpmyadmin 404 not found error


ln -s /usr/share/phpmyadmin /var/www/
service nginx restart

mysupermarket.com/phpmyadmin

enter user/password and login...this will redirecto below url

http://mysupermarket.com/index.php?token=81d1f26028dc0f0f625803c2d1ccd402

it will still give

ERROR 404 - Not Found!
The following error occurred:
The requested URL was not found on this server.
Please check the URL or contact the webmaster.

insert phpmyadmin between domain.com and index.php.... like below
http://mysupermarket.com/phpmyadmin/index.php?token=81d1f26028dc0f0f03c2d1ccd402#PMAURL:server=1&target=main.php&token=81d1f26028dc0f0f625803c2d1ccd402










still need to fix....


ispconfig 3 squirrelmail "Could not move/copy file. File not attached" when trying to attach a file"


1) create directory in /usr/share/squirrelmail/ for example attach - /usr/share/squirrelmail/attach

mkdir -p /usr/share/squirrelmail/attach

2) chmod 733 -R /usr/share/squirrelmail/attach
2) squirrelmail-configure
3) choose 4(General Options) and press Enter
4) choose 2(Attachment Directory) and paste ==>  /usr/share/squirrelmail/attach

press 'S' to save and exit
done !!

ispconfig 3 move spam to junk folder

http://www.geekonthepc.com/2012/01/23/configuring-anti-spam-spamassassin-in-ispconfig-3/

 ISPConfig relies on SpamAssassin – which is, when configured correctly, a very powerful spam filter. But for some reason, it just wasn’t working on my installation of ISPConfig. Spam would get through and it can get seriously frustrating!
Thankfully I now have it cracked – and wanted to share the configuration I chose for ISPConfig and SpamAssassin. I think the correct settings vary from person to person – but if you want general spam filtering, this should show you how to get it.

Instructions
First of all, make sure a ‘spamfilter’ policy is active both for the email domain you’re using and for each email mailbox. I chose the Uncensored policy in my case – but different rules apply to each setting. I found Uncensored to be most effective, but simply choosing this won’t make it work properly.
Once you’re happy that it’s supposedly on, you need to modify the rules for the policy you chose. Head to the ‘Email’ tab, and then from the left menu select ‘Policy’ under the ‘Spamfilter’ section (see screenshot that follows).
Select the policy you’re working with by simply clicking on it. Then select the ‘Tag-Level’ tab. This is where you set how sensitive SpamAssassin actually is. I found that the first three settings needed to be set as the following:
SPAM tag level: 3
SPAM tag2 level: 3.4
SPAM kill level: 5
The other settings requiring a number can be left alone. However, to make SPAM easier to separate, I’d suggest you turn on ‘SPAM modifies subject’ and choose a tag you’d like to add to SPAM emails. Here’s what the page might look like when you’re done (see screenshot that follows). 
Hit ‘Save’ and it’s a good’en. If you also want to move SPAM email to a seperate Junk folder, you can do so by going to the ‘Email Mailbox’ page from the left menu, then selecting your email account and clicking the ‘Mail Filter’ tab. Simply tick the ‘Move Spam Emails to Junk directory’ checkbox and dodgy email will be moved.
Hopefully that should get you going and stop infuriating SPAM emails reaching your inbox.