Friday, May 28, 2021

RHEL8- STIG, SCC, benchmark

 Task to do,

1. Install STIG viewer 2.14
2. Install SCC 5.4
3. Install benchmark


RHEL7 - Alternative to sys-unconfig command for Centos 7

 
Directly copied from
https://www.reddit.com/r/sysadmin/comments/8f10mc/command_sysunconfig_alternative_for_centos_7/

posted by user: ckozler

I posted, just to get an idea.

Command sys-unconfig alternative for Centos 7

-------------------------
I just made my own. I hated that they removed that

 #!/usr/bin/env bash
 
 #
 # This is the sys_prep script
 # It will clear out all non-revelent information for a new VM
 #
 # 1. Force logs to rotate and clear old.
 /usr/sbin/logrotate -f /etc/logrotate.conf
 /bin/rm -f /var/log/*-20* /var/log/*.gz
 #
 # 2. Clear the audit log & wtmp.
 /bin/cat /dev/null > /var/log/audit/audit.log
 /bin/cat /dev/null > /var/log/wtmp
 #
 # 3. Remove the udev device rules.
 /bin/rm -f /etc/udev/rules.d/70*
 #
 # 4. Remove the traces of the template MAC address and UUIDs.
 /bin/sed -i '/^\(HWADDR\|UUID\|IPADDR\|NETMASK\|GATEWAY\)=/d' /etc/sysconfig/network-scripts/ifcfg-e*
 #
 # 5. Clean /tmp out.
 /bin/rm -rf /tmp/*
 /bin/rm -rf /var/tmp/*
 #
 # 6. Remove the SSH host keys.
 /bin/rm -f /etc/ssh/*key*
 #
 # 7. Remove the root user's shell history.
 /bin/rm -f /root/.bash_history
 unset HISTFILE
 #
 # 8. Set hostname to localhost
 /bin/sed -i "s/HOSTNAME=.*/HOSTNAME=localhost.localdomain/g" /etc/sysconfig/network
 /bin/hostnamectl set-hostname localhost.localdomain
 
 #
 # 9. Remove rsyslog.conf remote log server IP.
 /bin/sed -i '/1.1.1.1.1/'d /etc/rsyslog.conf
 
 # 10. Clear out the osad-auth.conf file to stop dupliate IDs
 #
 rm -v /etc/sysconfig/rhn/osad-auth.conf
 rm -v /etc/sysconfig/rhn/systemid
 
 
 # clean hosts
 #hostname_check=$(hostname)
 #if ! [[ "${hostname_check}" =~ "local" ]]; then
 #    cp -v /etc/hosts /etc/hosts.sys_prep
 #    sed -i "s,$(hostname),,g" /etc/hosts
 #    sed -i "s,$(hostname -s),,g" /etc/hosts
 #fi
 
 rm -v /root/.ssh/known_hosts
 
 #
 # 11. Shutdown the VM. Poweron required to scan new HW addresses.
 poweroff
 #

--------------------------------

 Reply by
clearing_sky

-Use Cloud-Init. It should handle all the things you need to do, but a kickstart would probably be a better idea if you are doing a physical deployment.

Wednesday, May 26, 2021

HP - How to remove BIOS password

 How to remove BIOS password

HP ProLiant
- Reboot your machine
- When it prompts the password, enter the password followed by / (slash) no space.
- Password deleted message pops up.

say your password is BrIGht(!)Side@Edg3
you enter the password as: BrIGht(!)Side@Edg3/


Monday, May 24, 2021

Day8 - terraform, provider

 Day 8 - terraform


$ cat providers.tf





$ cat variables.tf

variable 'x' {
   default = "t2.micro"
     type = string
}

output "01" {
  value = var.x
}



> tf apply -var-'x-t2.medium"


$ cat aws-main.tf
resource "aws_instance" "web" {
  ami    = "ami-012...."
  instance_type    = var.x

}



$ cat variables.tf

# variable 'x' {
#    default = "t2.micro"
#     type = string
# }

variable 'x' {}

output "01" {
  value = var.x
}

> tf apply -var="x=t2.medium"

in this case, either you pass the value or it will prompt

don't change the code, pass the variable.

or you can create a config with key/value pair.

name must the same, fix file.
> notepad terraform.tfvars
#x="value"
x="t2.micro"

here, you can come and change
we change the value of x.

> tf apply

if you don't define, it will prompt but we defined, it will not prompt but will grab from config file.



> notepad terraform.tfvars
#x="value"
x="t2.large"

> tf apply -var="x=t2.micro"


Lets go to variable file


$ cat variables.tf

# variable 'x' {
#    default = "t2.micro"
#     type = string
# }

variable 'x' {}

variable "y" {
  type=boot

}


output "01" {
  value = var.y
}

commentout the content on aws_main.tf file.

> tf apply
ask you for true or false


boolean is good if you create condition
if you want to do something check the condition, if condition is true, do this if not do the else part.

turnety operator way ,,

condition - question mark? - value1: value2

if condition comes true, display value1 else display value2


Note: true and false should be on lower case

output "01" {
  value = var.y ? "Sam" : "Ram"
}

if true it will return Sam else Ram.



> cd google

provider "aws" {
 region    = "ap-south-1"
  profile    = "default"

}

provider "google" {
   project    = "myproj"
   region    = "asia-south1"
}


$ modify variable file

> tc apply

> tf plan

webapp    -> Testing (QA Team) -> Prod


$ cat aws_main.tf
resource "aws_instance" "web" {
 ami    = "ami-01..."
 instance_type = var.x
 count = 5

}


cat variables.tf
append
variable "lstest" {
type = bool

}

change the value of 5

$ cat aws_main.tf
resource "aws_instance" "web" {
 ami    = "ami-01..."
 instance_type = var.x
# count = 5
 count = var.lstest ? 0    : 1    # if this is true, 0 , count 0 , this instance will not run

}


gcp_main.tf
resource "google_compute_instance" os1" {
  name    = "os1"
  machine_type = var.mtype
  zone    = "asia-south-c"
  count = var.istest ? 1 : 0

boot_disk {
  initialize_params {
    image = "debian-cloud/debian-g"
  }
}

> tf apply -var="lstest=true"


ca variables.tf
append


variable "lstest" {
type = bool

}

variable "azaws" {
default = [ "ap-south-1a", "ap-south-1b", "ap-south-1c" ]
type = list
}

#output "0s2" {
#  value = var.azaws


$ cat aws_main.tf
resource "aws_instance" "web" {
 ami    = "ami-01..."
 instance_type = var.x
 availability_zone = var.azaws[1]
 count = 1

}


> tf apply




map data type

[ 'a', 'b', 'c' ]

system gives the index

you may want to do your own value
say a is id




variable "azaws" {
default = [ "ap-south-1a", "ap-south-1b", "ap-south-1c" ]
type = list
}

variable "types" {
  type = map
  default = {        # maps in curly braces
    us-est-1 = "t2.nano",
        ap-south-1 = "t2.micro",
        us-west-1 = "t2.medium"
  }
}


# output "os3" {
#   value = var.types
#   value = var.types["ap-south-1"]
# }


> tf apply




when your signature becomes autograph you are something ...


RHEL8 - YUM Repository Setup, SELinux, IPv6 set up

 In SELinux, Context is set up on a file and you can see it with ls -lZ command.
$ ls -lZ

On the output, you can see the context set on user base (_u), role(_r), type(_t), or the Security label (_t)

--------------------------

Yum repo set up

- AppSteam | BaseOS | YUM Repository Setup RHEL8

BaseOS - Required Software

# mkdir /rpms

Go to your DVD and copy AppStream and BaseOS directories which contains importaint packages.
# cd /mnt; ls
# cp -aRv BaseOS AppStreas  /rpms
# cd /etc/yum.repos.d
# vi appstream.repo
[AppStream-Repo]
name="App Sreadm Repo"
baseurl=file:///rpms/AppStream/
enabled=1
gpgcheck=0

# cat baseos-repo.repo

[BaseOS-Repo]
name="BaseOS Repo"
baseurl=file:///rpms/BaseOS/
enabled=1
gpgcheck=0

# yum clean all
# yum repolist

Register all packages (sign with gpg key)
# rpm --import RMP-GPG-KEY-redhat-release


raaho ke jamate ke tujhe kya sabut diun
manjil mile to paawo ke chhale nahi rahe
chalte chalte mujhse puchha mere paheron ki chhlon ne
kitne dur maiful sajadi rahiso waalone

# IPv6 set up
# nmcli connection show
# ip addr
# nmcli conn modify eni123 ipv6.addresses "<IP-V6 address>" ipv6.method manual
# ip a
# nmcli con down eno123
# nmcli con up eno123
# ping6 <IPv-6_address>

# vi /etc/syconfig/network-scripts/ifcfg-eno123
IPV6INIT=:yes"


# nmcli connection modyf eno123 ipv6.addresses "IPv6" ipv6.method manual
# nmcli conn down eno123
# nmcli conn up eno123
# ip addr
# ping6 <ipv-6 address>





SAN Switch - Configure MAPS email alerts on SAN switch (Brocade Switch)

 Configure MAPS email alerts on SAN switch (Brocade Switch)
- deliver your alerts to your email

Pre-req tasks
- Complete domain server configuration (AD-Account set up)
- Set up smart reply server to filter email coming from outside to the switch (Optional)

> mapsconfig --show
> dnsconfig --add -domain -switch1
> dnsconfig --show

> relayconfig --config -rla_ip -rla_dname
> relayconfig --show    # verify

1. Display config info
> mapsconfig --show

2. Set the confi
> mapsconfig --emailcfg -address root@everest.local
> mapsconfig --testmail -subject "Test" -message "Test message from `hostname`"
> mapsconfig --actions raslog,email,sw_critical,sw_marginal,sfp_marginal

or
> mapsconfig --action email

> mspsconfig --emailcfg -address
> mapsconfig --show

send test message (email)
> mapsconfig --testmail -subject Test Mail -message Testing

3. Verify the change
> mapsconfig --show


Thursday, May 20, 2021

Amazon: Leadership Principles

 https://www.amazon.jobs/en/principles

Leadership Principles

We use our Leadership Principles every day, whether we're discussing ideas for new projects or deciding on the best approach to solving a problem. It is just one of the things that makes Amazon peculiar.

Customer Obsession

Leaders start with the customer and work backwards. They work vigorously to earn and keep customer trust. Although leaders pay attention to competitors, they obsess over customers.

Ownership

Leaders are owners. They think long term and don’t sacrifice long-term value for short-term results. They act on behalf of the entire company, beyond just their own team. They never say “that’s not my job."

Invent and Simplify

Leaders expect and require innovation and invention from their teams and always find ways to simplify. They are externally aware, look for new ideas from everywhere, and are not limited by “not invented here." As we do new things, we accept that we may be misunderstood for long periods of time.

Are Right, A Lot

Leaders are right a lot. They have strong judgment and good instincts. They seek diverse perspectives and work to disconfirm their beliefs.

Learn and Be Curious

Leaders are never done learning and always seek to improve themselves. They are curious about new possibilities and act to explore them.

Hire and Develop the Best

Leaders raise the performance bar with every hire and promotion. They recognize exceptional talent, and willingly move them throughout the organization. Leaders develop leaders and take seriously their role in coaching others. We work on behalf of our people to invent mechanisms for development like Career Choice.

Insist on the Highest Standards

Leaders have relentlessly high standards — many people may think these standards are unreasonably high. Leaders are continually raising the bar and drive their teams to deliver high quality products, services, and processes. Leaders ensure that defects do not get sent down the line and that problems are fixed so they stay fixed.

Think Big

Thinking small is a self-fulfilling prophecy. Leaders create and communicate a bold direction that inspires results. They think differently and look around corners for ways to serve customers.

Bias for Action

Speed matters in business. Many decisions and actions are reversible and do not need extensive study. We value calculated risk taking. 

Frugality

Accomplish more with less. Constraints breed resourcefulness, self-sufficiency, and invention. There are no extra points for growing headcount, budget size, or fixed expense.

Earn Trust

Leaders listen attentively, speak candidly, and treat others respectfully. They are vocally self-critical, even when doing so is awkward or embarrassing. Leaders do not believe their or their team’s body odor smells of perfume. They benchmark themselves and their teams against the best.

Dive Deep

Leaders operate at all levels, stay connected to the details, audit frequently, and are skeptical when metrics and anecdote differ. No task is beneath them.

Have Backbone; Disagree and Commit

Leaders are obligated to respectfully challenge decisions when they disagree, even when doing so is uncomfortable or exhausting. Leaders have conviction and are tenacious. They do not compromise for the sake of social cohesion. Once a decision is determined, they commit wholly.

Deliver Results

Leaders focus on the key inputs for their business and deliver them with the right quality and in a timely fashion. Despite setbacks, they rise to the occasion and never settle.

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...