Thursday, 3 October 2019

how to find out running tomcat version in linux or windows

We can find it in different ways

1) from version sh file you can find the version.sh file location in linux by 

   
sudo find / -name "version.sh"
then just execute it
./version.sh

Output would be
Using CATALINA_BASE:   /usr/share/tomcat7
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.28
Server built:   Apr 8 2014 08:47:08
Server number:  7.0.28.0
OS Name:        Linux
OS Version:     3.15.4-x86_64-linode45
Architecture:   amd64
JVM Version:    1.7.0_55-b14

JVM Vendor:     Oracle Corporation


2) by catalina jar


First, find catalina.jar by using below command on linux

sudo find / -name "catalina.jar"

if you are using windows then you will find it in apache installation directory

run below command to get the version

java -cp catalina.jar org.apache.catalina.util.ServerInfo

it will give below output

Server version: Apache Tomcat/8.0.50
Server built:   Mar 20 2018 20:30:11 UTC
Server number:  8.0.50.0
OS Name:        Linux
OS Version:     4.14.47-56.37.amzn1.x86_64
Architecture:   amd64
JVM Version:    1.8.0_171-b10
JVM Vendor:     Oracle Corporation

Monday, 30 September 2019

Check AWS S3 encryption from CLI

Check AWS S3 encryption from CLI

There different ways to encryption AWS S3 from CLI. The secret is from AWS CLI, you can leverage the functions normally exposed by the AWS REST APIs.
  • Use put-bucket-encryption

This would setup the default encryption for S3 bucket,
$ aws s3api put-bucket-encryption --bucket <Bucket Name> --server-side-encryption-configuration '{
  "Rules": [
    {
      "ApplyServerSideEncryptionByDefault": {
        "SSEAlgorithm": "AES256"
      }
    }
  ]
}'
To check the default encryption setup, use the following command:
$ aws s3api get-bucket-encryption --bucket withsin2
{
    "ServerSideEncryptionConfiguration": {
        "Rules": [
            {
                "ApplyServerSideEncryptionByDefault": {
                    "SSEAlgorithm": "AES256"
                }
            }
        ]
    }
}
  • Use copy-object

For existing buckets or objects in the bucket, use copy-object to encrypt.
$ aws s3api copy-object --copy-source <Bucket Name>/<Object Name> --key <Key Name> --bucket <Bucket Name> --server-side-encryption aws:kms
Use the following command to check whether the object is encrypted or not.
aws s3api head-object --bucket <Bucket Name> --key <Key Name>

Wednesday, 22 August 2018

List of Git commands which are mostly used by developer for managing branches

Git Commands

Clone branch from git repository
git clone gitrepourl

List all local branch of the repository
git branch

Fetch branch from repository
git fetch origin remoteBranchName:localNewName

Create branch from repository
git checkout -b newBranchName

Pull the remote changes of the branch
git pull origin remoteBranchName

Push changes to remote branch
git push origin remote branch name

Rename local branch locally
checkout branch you want to rename
git branch -m newName

Rename local branch locally when you are in different branch 
git branch -m oldname newname

Delete local branch
git branch -d nameOfBranch

Delete remote local branch
git push origin -d nameOfBranch

Delete old named remote branch and push new named local branch
git push origin :oldname newname

Replace local changes or get back locally deleted file from the remote branch
git checkout HEAD yourfile or directory path

Merge command for merging branch with current branch
git merge --no-ff branchNameYouWantToMerge

Commit staged change to branch
git commit -m "your comment"

Revert commit from the branch
git revert commitID
Use --no-commit perameter if you dont want to commit automatically after reverting

Revert merged commits
git revert -m 1 commitID








Tuesday, 24 April 2018

Allow multiple domain in X-Frame-Options ALLOW-FROM

We can allow domain which can embed our web site domain in their iframe src using 'X-Frame-Options ALLOW-FROM uri'. More Details

Just by adding X-Frame-Options parameter in response header.

But, ALLOW-FROM uri parameter is not working with the chrome browser.
As it is not supported by chrome we can not get the benefits of using X-Frame-Options ALLOW-FROM parameter.
ALLOW-FROM is also not supporting multiple domain in its parameter value so, here is a alternative solution for that.

Add Header
X-Frame-Options SAMEORIGIN

And

Content-Security-Policy "frame-ancestors 'self' domain1 domain2 domain3"

More Detail about content-security-policy.com
Please take not that single quote around self is added otherwise is may not work properly.