Wednesday, April 19, 2023

How to give privilege for access of single aws bucket ..

 {

    "Version": "2012-10-17",

    "Statement": [

        {

            "Effect": "Allow",

            "Action": [

                "s3:PutObject",

                "s3:ListBucket"

            ],

            "Resource": "arn:aws:s3:::bucket_name*"

        }

    ]

}


$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

After aws cli configure on windows machine . we can list the bucket.

$ aws s3 ls s3://bucket_name/




Thursday, September 9, 2021

How to Install MySQL 8.0 in Ubuntu 18.04

 #### How to Install MySQL 8.0 in Ubuntu 18.04 ####


## Step 1: Add MySQL Apt Repository


$ wget -c https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb 



# Then install the MySQL repository package using the following dpkg command.


$ sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb 


# Step 2: Install MySQL Server in Ubuntu 18.04

       Next, download the latest package information from all configured repositories, including the recently added MySQL repository.


$ sudo apt update


# Then run the following command to install packages for the MySQL community server, client and the database common files.


$ sudo apt-get install mysql-server


# Step 3: Secure MySQL Server Installation


$ sudo mysql_secure_installation



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


##################### CREATE Database User and ALTER Password #############################



#SET GLOBAL validate_password.policy=LOW;

#CREATE USER 'india'@'%' IDENTIFIED WITH mysql_native_password BY 'SF9kh77hjjg8g';(8 ok)

mysql> ALTER USER 'india'@'localhost' IDENTIFIED BY 'SF9kh77hjjg8g';

mysql> flush privileges;

#ALTER USER 'india'@'%' IDENTIFIED WITH mysql_native_password BY 'SF9kh77hjjg8g';(8 ok)

#GRANT ALL PRIVILEGES ON * .* TO 'india'@'%';


Wednesday, September 8, 2021

Tomcat 9 install on centos 7 and aws linux 2

 Tomcat9 install on centos 7 and aws linux 2


sudo yum install java-1.8.0-openjdk-devel


java –version


Create Tomcat User and Group

Tomcat should not be run as root. Create a new user and group by entering:


sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat

Download Tomcat 9

Tomcat 9.0.20 is the latest version at the time this was written. A later release may be available on the official download page. Alternately, enter the following:


cd /tmp

wget http://apache.cs.utah.edu/tomcat/tomcat-9/v9.0.20/bin/apache-tomcat-9.0.20.tar.gz

Extract the .tar.gz File

To extract the Tomcat tar.gz file, enter the following:


tar -xf apache-tomcat-9.0.20.tar.gz

Move the files to the /opt/tomcat directory:


sudo mv apache-tomcat-9.0.20 /opt/tomcat/

(Optional) Create a symbolic link for updates:


sudo ln -s /opt/tomcat/apache-tomcat-9.0.20 /opt/tomcat/latest

Modify Tomcat User Permissions

The new users needs to execute privileges over the directory.


Enter the following:


sudo chown -R tomcat:tomcat /opt/tomcat

sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'

Create a System Unit File

Creating a systems unit file allows Tomcat to run as a service.


1. To create a tomcat.service file, use the command:


sudo nano /etc/systemd/system/tomcat.service

2. In the file, enter the following:


[Unit]

Description=Tomcat 9 servlet container

After=network.target

[Service]

Type=forking

User=tomcat

Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/jre"

Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/opt/tomcat/latest"

Environment="CATALINA_HOME=/opt/tomcat/latest"

Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"

Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/latest/bin/startup.sh

ExecStop=/opt/tomcat/latest/bin/shutdown.sh

[Install]

WantedBy=multi-user.target


3. Save and close the file.


4. Refresh the system:


sudo systemctl daemon-reload

5. Set the Tomcat service to start on boot:


sudo systemctl enable tomcat

6. Start the Tomcat service:


sudo systemctl start tomcat

7. Verify that the Tomcat service is installed and running:


sudo systemctl status tomcat



Adjust the Firewall

The Tomcat service needs access to Port 8080.


Allow traffic by entering the commands:


firewall-cmd --zone=public --permanent --add-port=8080/tcp

firewall-cmd -reload

You should be able to see the Tomcat server in a web browser.


Input this web address into a browser window:


http://server_ip:8080

Thursday, July 15, 2021

How to change port number of Tomcat 8080 to 80

How to change port number  of Tomcat default to 80

# cd /opt/tomcat/conf

@ Edit  <Connector port="80" protocol="HTTP/1.1"


 $$$ Run below command after change port number 8080 to 80 in server.xml $$$

# cd /opt/tomcat/bin

# ./shutdown.sh

# ./startup.sh

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# sudo apt-get install iptables

# apt install net-tools -y


# iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80

# 192.168.0.10


Wednesday, June 30, 2021

How To get Aws DB Snapshots list from aws cli and scripting

 #!/bin/bash

aws  rds --output text describe-db-snapshots --db-instance-identifier databaseName --query 'DBSnapshots[*].[DBInstanceIdentifier, AllocatedStorage, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' >  databaseName.csv

# single comand for snapshots
aws ec2 describe-snapshots --output text --query 'Snapshots[*]
 [Description,Encrypted,OwnerId,Progress,SnapshotId,StartTime,State,VolumeId,VolumeSize,OwnerAlias]' >  b.txt


# snapshots get by snapshot-type (manual)
 aws  rds --output text describe-db-snapshots --snapshot-type manual  --db-instance-identifier database-1 --query 'DBSnapshots[*].[DBInstanceIdentifier, AllocatedStorage, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' > a2.csv

#aws  rds --output text describe-db-snapshots --query 'DBSnapshots[*].[DBInstanceIdentifier, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' > a.csv

#aws  rds --output text describe-db-snapshots --snapshot-type manual  --db-instance-identifier database-1 --query 'DBSnapshots[*].[DBInstanceIdentifier, AllocatedStorage, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' > a2.csv

# aws  rds describe-db-snapshots --db-instance-identifier database-1--snapshot-type manual | jq '[.DBSnapshots[] | {Snapshot_Identifier:.DBSnapshotIdentifier,Creationtime:.SnapshotCreateTime}]'

Thursday, June 10, 2021

Installation of Tomcat 9 on Ubuntu 18

 Java installation in Ubuntu  18.....

  

  # sudo apt install openjdk-8-jdk

  # java -version

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Create Tomcat User

# sudo groupadd tomcat

# sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

# sudo apt update

Dawnload Package of Tomcat 9

# cd /tmp

#  sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.21/bin/apache-tomcat-9.0.21.tar.gz

# sudo mkdir /opt/tomcat

# sudo tar xzvf apache-tomcat-*tar.gz -C /opt/tomcat --strip-components=1

#  ll /opt/tomcat/

#  sudo chown -R tomcat: tomcat

#  sudo chmod o+x /opt/tomcat/bin/

Update Permissions

   #  cd /opt/tomcat


Give the tomcat group ownership over the entire installation directory:

    #  sudo chgrp -R tomcat /opt/tomcat

Give the tomcat group read access to the conf directory and all of its contents, and execute access to the directory itself:  

    #  sudo chmod -R g+r conf

    #  sudo chmod g+x conf

 

 Make the tomcat user the owner of the webapps, work, temp, and logs directories:

    # sudo chown -R tomcat webapps/ work/ temp/ logs/


Create a systemd Service File

    # sudo update-java-alternatives -l

!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# sudo vi /etc/systemd/system/tomcat.service

[Unit]

Description=Apache Tomcat Web Application Container

After=network.target


[Service]

Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid

Environment=CATALINA_HOME=/opt/tomcat

Environment=CATALINA_BASE=/opt/tomcat

Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'

Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'


ExecStart=/opt/tomcat/bin/startup.sh

ExecStop=/opt/tomcat/bin/shutdown.sh


User=tomcat

Group=tomcat

UMask=0007

RestartSec=10

Restart=always

[Install]

WantedBy=multi-user.target

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# sudo systemctl daemon-reload

# sudo systemctl start tomcat

# sudo systemctl status tomcat

Add Port on Firewall

# sudo ufw allow 8080

# http://server_domain_or_IP:8080

How to give privilege for access of single aws bucket ..

 {     "Version": "2012-10-17",     "Statement": [         {             "Effect": "Allow"...