Friday, July 23, 2021

Some HP Servers

Some HP servers

HPE DL325 G10 128GB 24 cores
HPE DL380p 384 GB 24 cores
HPE DL580 G10 3TB RAM 88 cores
SuperDome Flex 14TB 288 cores




 

 

Tuesday, July 20, 2021

ROM Flash Component for Linux - HPE ProLiant DL325 Gen10 (A41) Servers

 ROM Flash Component for Linux - HPE ProLiant DL325 Gen10 (A41) Servers

 HPE A41 - Bios update

 Download the software

Multi-part downloadFile name:    firmware-system-a41-2.20_2019_09_17-1.1.x86_64.compsig (2.0 KB)   
File name:    firmware-system-a41-2.20_2019_09_17-1.1.x86_64.rpm (16 MB)

 Installation:

To update firmware from Linux operating system on target server:

Install the RPM package
> rpm -Uvh <filename>.rpm

See where the files land
> rpm -qlp <filename>.rpm

Change to the directory you see in the previous step and run hpsetup by typing ‘./hpsetup’ at the command prompt.

 # cd /usr/lib/x86_64-linux-gnu/firmware.../

# ./hpsetup

login with your iLO management account/PW when prompted

type 'y' and enter to update the software.


when prompt for reboot, say y.

 

Reboot Requirement:
Reboot is required after installation for updates to take effect and hardware stability to be maintained.

https://support.hpe.com/hpesc/public/swd/detail?swItemId=MTX-531cc9e031d243a48b39a6430f#tab3

 

 

 

How to create a Linux RPM package

 

How to create a Linux RPM package

You've written a great script that you want to distribute, so why not package it as an RPM?
Image
How to create a Linux RPM package

Photo by Ketut Subiyanto from Pexels

This article shows you how to package a script into an RPM file for easy installation, updating, and removal from your Linux systems. Before I jump into the details, I'll explain what an RPM package is, and how you can install, query, remove, and, most importantly, create one yourself.

This article covers:

  • What an RPM package is.
  • How to create an RPM package.
  • How to install, query, and remove an RPM package.

What is an RPM package?

RPM stands for Red Hat Package Manager. It was developed by Red Hat and is primarily used on Red Hat-based Linux operating systems (Fedora, CentOS, RHEL, etc.).

An RPM package uses the .rpm extension and is a bundle (a collection) of different files. It can contain the following:

  • Binary files, also known as executables (nmap, stat, xattr, ssh, sshd, etc.).
  • Configuration files (sshd.conf, updatedb.conf, logrotate.conf, etc.).
  • Documentation files (README, TODO, AUTHOR, etc.).

The name of every RPM package is comprised as follows:

<name>-<version>-<release>.<arch>.rpm

An example:

bdsync-0.11.1-1.x86_64.rpm

[ You might also enjoy: Linux package management with YUM and RPM ]

How to create an RPM package

You'll need the following components to build an RPM package:

  • A workstation or a virtual machine (I am using Fedora 32 on a virtual machine).
  • Software to build the package.
  • Source code to package.
  • SPEC file to build the RPM.

Installing the required software

The following packages need to be installed to build the RPM package:

$ sudo dnf install -y rpmdevtools rpmlint

After installing rpmdevtools, we can run the following as a user called sai.local:

$ rpmdev-setuptree

Note: Do not build RPM packages as the root user. This is highly discouraged.

The above command creates the following directory structure:

rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
  • The BUILD directory is used during the build process of the RPM package. This is where the temporary files are stored, moved around, etc.
  • The RPMS directory holds RPM packages built for different architectures and noarch if specified in .spec file or during the build.
  • The SOURCES directory, as the name implies, holds sources. This can be a simple script, a complex C project that needs to be compiled, a pre-compiled program, etc. Usually, the sources are compressed as .tar.gz or .tgz files.
  • The SPEC directory contains the .spec files. The .spec file defines how a package is built. More on that later.
  • The SRPMS directory holds the .src.rpm packages. A Source RPM package doesn’t belong to an architecture or distribution. The actual .rpm package build is based on the .src.rpm package.

A .src.rpm package is very flexible since it can be built and re-built on every other RPM-based distribution and architecture.

Since you're now familiar with what each directory holds, here's how to create a simple but functional bash script that I'll show you how to package.

Create the bash script

You are probably familiar with the following error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
da:ea:16:ff:db:d3:5c:0c:12:11:de:dd:2d:ba:fd:2a.
Please contact your system administrator.
Add correct host key in /home/foo/.ssh/known_hosts to get rid of this message.
Offending key in /home/foo/.ssh/known_hosts:42
RSA host key for domain.com has changed, and you have requested strict checking.
Host key verification failed.

So the purpose of this bash script is to remove the offending key from ~/.known_hosts without having to manually edit the file and remove 42.

Note that ssh-keygen -R didn’t work in my case, so I created a script called rm-ssh-offendingkey to automate this process. Here it is:

#!/usr/bin/env bash

rmoffendingKey()
{
  local offendingKey="$1"
  local st=1
  if [[ ! -z $offendingKey && $offendingKey =~ [[:digit:]] ]]; then
    sed -i "${offendingKey}d" ~/.ssh/known_hosts
    st=$?
  else
    printf '%s\n' "You need to provide a line number" >&2
  fi  
  return $st
}
rmoffendingKey “$1”

Place the script in the designated directory

To build the script, you need to put it in the directory the RPM build process is expecting it to be in. Create the directory structure:

$ mkdir p ~/rpmbuild/SOURCES/sshscript-1/rm-ssh-offendingkey/

Put the rm-ssh-offendingkey script in the sshscript-1/rm-ssh-offendingkey directory.

Subsequently, I .tar.gz the source as follows:

$ cd ~/rpmbuild/SOURCES/ && tar zcvf sshscripts-1.tar.gz sshscripts-1/

Create the .spec file

To be able to package the script, you need to create a .spec file. To make a default .spec file for the package, I am going to use the following syntax:

rpmdev-newspec rm-ssh-offendingkey

Now let’s run tree ~/rpmbuild to see what the directory structure looks like:

/home/sai.local/rpmbuild/
├── BUILD
├── BUILDROOT
├── RPMS
├── SOURCES
│   └── sshscripts-1
│       └── rm-ssh-offendingkey-1
│           └── rm-ssh-offendingkey
├── SPECS
│   └── rm-ssh-offendingkey.spec
└── SRPMS

The generated rm-ssh-offendingkey.spec file needs some modifications. The generated .spec file assumes that I am going to compile and build software. Since I'm packaging a simple bash script, I'll remove some unnecessary lines from the .spec file and add others. For example, I added Requires: bash so that the package requires bash to be installed as well. I also added BuildArch: noarch which means that the package should work on a 32-bit and a 64-bit CPU architecture.

Name:           sshscripts
Version:        1
Release:        0
Summary:        A simple bash script to remove ssh offending key from known hosts
BuildArch:      noarch

License:        GPL
#URL:            
Source0:        %{name}-%{version}.tar.gz

#BuildRequires:  
Requires:       bash

%description
This is a simple script that somehow automates the removal of ssh offending key from the ~/.ssh/known_hosts file

%prep
%setup -q

%build

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
cp rm-ssh-offendingkey-1/* $RPM_BUILD_ROOT/%{_bindir}

%clean
rm -rf $RPM_BUILD_ROOT

%files
%{_bindir}/rm-ssh-offendingkey

%changelog
* Sun Nov  8 2020 Valentin Bajrami <valentin.bajrami@slimmer.ai> - 0.1
- First version being packaged

It's important to specify which files are going to be installed under the %files section. Here I’ve explicitly put the following line:

%files
%{_bindir}/rm-ssh-offendingkey

This is sufficient since I only want this script to go to /usr/bin. Oh, by the way, %{_bindir} is called a macro and translates to /usr/bin. You can verify this by running:

$> rpm --eval '%{_bindir}'
/usr/bin

Other useful macros to be aware of are:

Macro          Translates to
%{_sbindir}    /usr/sbin
%{_datadir}    /usr/share
%{_sysconfdir}    /etc

Checking the .spec file on error (rpmlint)

At the beginning of the article, I installed the rpmlint package along with rpmdev-tools, which helps me to check the .spec file for errors.

$ rpmlint ~/rpmbuild/SPECS/rm-ssh-ffendingkey.spec
/home/sai.local/rpmbuild/SPECS/rm-ssh-ffendingkey.spec: W: invalid-url Source0: sshscripts-1.tar.gz
0 packages and 1 specfiles checked; 0 errors, 1 warnings.

Everthing looks good.

Building the package (rpmbuild)

To build the RPM package you can use the rpmbuild command. Earlier in this tutorial, I mentioned the difference between the .src.rpm (Source RPM package) and the .rpm package.

To create the .src rpm package, use:

$ rpmbuild -bs ~/rpmbuild/SPECS/rm-ssh-offendingkey.spec

The flags -bs have the following meanings:

  • -b | build
  • -s | source

To create the binary .rpm package, use:

$ rpmbuild -bb ~/rpmbuild/SPECS/rm-ssh-offendingkey.spec

The flags -bb have the following meanings:

  • -b | build
  • -b | binary

If all goes well, you now have the following directory structure:

$ tree ~/rpmbuild/
/home/sai.local/rpmbuild/
├── BUILD
│   └── sshscripts-1
│       ├── debugfiles.list
│       ├── debuglinks.list
│       ├── debugsourcefiles.list
│       ├── debugsources.list
│       ├── elfbins.list
│       └── rm-ssh-offendingkey-1
│           └── rm-ssh-offendingkey
├── BUILDROOT
├── RPMS
│   └── noarch
│       └── sshscripts-1-0.noarch.rpm
├── SOURCES
│   ├── sshscripts-1
│   │   └── rm-ssh-offendingkey-1
│   │       └── rm-ssh-offendingkey
│   └── sshscripts-1.tar.gz
├── SPECS
│   └── rm-ssh-offendingkey.spec
└── SRPMS

11 directories, 10 files

The following lines are indicating that the RPM package has successfully been built.

├── RPMS
│   └── noarch
│       └── sshscripts-1-0.noarch.rpm

Installing the RPM package

After a successful build of the package, you now can install the RPM package as follows:

$ sudo rpm -ivh ~/rpmbuild/RPMS/noarch/sshscripts-1-0.noarch.rpm

Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:sshscripts-1-0                   ################################# [100%]

Verifying the package has been installed

To verify the package has correctly been installed, run the following command:

$ rpm -qi sshscripts-1
Name        : sshscripts
Version     : 1
Release     : 0
Architecture: noarch
Install Date: Mon 09 Nov 2020 01:29:51 AM CET
Group       : Unspecified
Size        : 294
License     : GPL
Signature   : (none)
Source RPM  : sshscripts-1-0.src.rpm
Build Date  : Mon 09 Nov 2020 01:08:14 AM CET
Build Host  : slimmerAI
Summary     : A simple bash script to remove ssh offending key from known hosts
Description :
This is a simple script that somehow automates the removal of ssh offending key from the ~/.ssh/known_hosts file

Querying some more info about the package, in the spec file, I did add a %changelog entry. This %changelog entry can be viewed as follows:

$ rpm -q sshscripts-1 --changelog
* Sun Nov 08 2020 Valentin Bajrami <valentin.bajrami@slimmer.ai> - 0.1
- First version being packaged

See what’s in the RPM package

It is very easy and quite convenient to see which files an RPM package contains. This information is retrieved as follows:

$ rpm -ql sshscripts-1
/usr/bin/rm-ssh-offendingkey

Removing the RPM package

Removing the package from the system is just as easy as installing it.

$ sudo rpm -ve sshscripts-1
[sudo] password for sai.local:
Preparing packages...
sshscripts-1-0.noarch
  • - v | verbose
  • - e | erase

Final thoughts

In this document, I covered the very basics of an RPM package, including how to build, install, and remove it from your system. The .spec file can get very complicated as you build more advanced software. If you plan to continue your journey on building RPM packages, don’t forget to check out mock and the mock GitHub page.


https://www.redhat.com/sysadmin/create-rpm-package

https://www.redhat.com/en/services/training/rh024-red-hat-linux-technical-overview?intcmp=701f20000012ngPAAQ&section=Outcomes

CommVault - Creating a CA-Signed Certificate for the Tomcat Server

 Creating a CA-Signed Certificate for the Tomcat Server

Procedure

1. From the command prompt, go to the folder that contains the keytool.exe file:
 - For Windows systems, go to C:\Program Files\Commvault\ContentStore\jre\bin.
 - For Linux systems, go to /usr/lib/jvm/jdkx/bin.


2. To create the keystore file containing the key-pair/certificate to be signed, run the following command:

For Windows:
> keytool -genkey -alias tomcat -keyalg RSA -keystore "C:\mykeystore.jks" -ext SAN=dns:<domainname>
> keytool -genkey -alias tomcat -keyalg RSA -keystore "C:\mykeystore.jks" -ext "SAN=dns:myserv.eg.com,dns:cnameserv.eg.com,EMAIL:admin@eg.com"

For Linux:
# keytool -genkey -alias tomcat -keyalg RSA -keystore "/mykeystore.jks" -ext SAN=dns:<domainname>


3. Generate a CSR, run the following command:

keytool -certreq -keyalg RSA -alias tomcat -file C:\tomcat.csr -keystore C:\mykeystore.jks -validity <daysValid> -ext SAN=dns:<domainname>

keytool -certreq -keyalg RSA -alias tomcat -file C:\tomcat.csr -keystore C:\mykeystore.jks -validity 365 -ext SAN=dns:myserv.eg.com,dns:cnameserv.eg.com

4. Upload the CSR to the CA website, indicate the type of Tomcat server, and submit for signing.
5. Download the root, intermediate, and issued server/domain certificates.

6. Import each signed certificate that is issued by the CA using the following commands:

    a. Root certificate:
    keytool -import -alias root -keystore C:\mykeystore.jks -trustcacerts -file C:\valicert_class2_root.crt

    b. Intermediate certificate:
    keytool -import -alias intermed -keystore C:\mykeystore.jks -trustcacerts -file C:\gd_intermediate.crt

    c. Issued server/domain certificate:
    keytool -import -alias tomcat -keystore C:\mykeystore.jks -trustcacerts -file C:\server_certificate_whatevername.crt


Note: The keystore parameter must be the path to the keystore file that was used to generate the CSR. You must use the same keystore file throughout this procedure.


7. Configure certificate
1. Stop the Tomcat Server.
2. Go to software_installation_path/Apache/Conf, and then back up the server.xml file that is part of the Apache configuration.
3. Copy the generated keystore file to software_installation_path/Apache.

4. For new installations of Version 11 SP9 or higher, in the server.xml file, modify the path to the generated keystore file and the keystore password values:

<Certificate certificateKeystoreFile="software_installation_path/Apache/your_file" certificateKeystorePassword="password" certificateKeystoreType="JKS"/>

8. Restart the service
a. Click Start and point to All Programs.
b. Click Commvault > Process Manager.
c. Under the Services tab, right-click a running service and then click Restart.



https://documentation.commvault.com/commvault/v11/article?p=50497.htm

Windows - Registry backup in Windows Server 2019/2016

 Registry backup in Windows Server 2019/2016

Press WinKey+R or R click on start menu and click on Run
- Type regedit and click ok
-> Click on file -> Export
-> Specify the location and save it with today's data: regedit_bk_07202021

Restore registry from backup
-> Open the registry editor
-> Click on file -> import
-> Specify the backup location
-> Select the file you downloaded before
-> wait for a while, done ..

Paste from Notepad into Word without getting extra line breaks after every line

How to paste content from notes to windows words without line break?


Win-Word adds spacing after each paragraph, and it considers each pasted line a new paragraph.

Solution:
-> Select all text (e.g. Control-A)
-> Right-click the selected text
-> Then select Paragraph.
-> Check the box "Don't add space between paragraphs of the same style



Friday, July 16, 2021

pyton class

 Session 14:  7/15/2021

Review
<syntax2>
if <condition>:
  st1
  st2
else:
  st3
  st4



a=int(input("Enter first number"))
b=int(input("Please enter 2nd number"))

if a>b:
  print("A is greater then B")
else:
  print("A is less than B"


====================================

When will you go for if elif else?
When we have more than 2 options to choose from based on condition, we will use if elif else.
In this case, if the condition is true, it will execute the statement and skips the rest of the statement.

On the other hand, if if condition is false, the control will go to elif part and executes and else part skips. but if elif is false, then executes the else part.



Write a python program to accept one letter and check if it is vowel or not?

Step1: Design with o/p
----------------------

o/p
-------------------------
enter your letter:
user enters a, store a into a variable called letter: a
return: it is vowel.
Enter your letter:
user enter b, store b into variable called letter: b
return: its not a vowel.

coding
--------
letter=input("Enter your letter")
if letter=='a':
  print("It is a vowel")
elif letter=='e':
  print("It is a vowel")
elif letter=='i':
  print("It is a vowel')
elif letter=='o':
  print("It is a vowel')
elif letter=='u':
  print("It is a vowel")
else
  print("It is not a vowel")

When you run this code
input - enter ur letter
user enters a
a=a
condition is true, the it is vowel and rest of the condition is skips.

run it again
user enters b
b=a -> false , skips
b=e and keep checking and it will go to else part and returns the value
it is not vowel.

In this code we have 6 conditions, one for vower and other for consonent

Task1:
implement above program by using if else?

letter=input("Enter a letter")
if(letter=='a'|'e'|'i'|'o'|'u'):
  print("The letter is vowel")
else:
  print("The letter is not a vowel"


task2
Implement above vowel program by using if else and which should handle casesensitive?

Step1: Design with 0/p
=======================

le=input("Enter a letter")
if (le=='A' or le='a' or le=='E' or le=='e' or le=='I' or le=='i' or le=='o' or le=='O' or le=='U' or le=='u'):
  print(le, "is a vowel")
else
  print(le, "is not a consonant")


Task3
-----
Write a python program to accept student 3 subject marks and display the result?

Step1: Design with O/P
----------------------

o/p
----------
Enter m1 marks: 60
enter m2 marks: 70
enter m3 marks: 80

m1+m2+m3 = 60+70+80 = totmarks
totmarks/3 -> avg marks

Now display result
result can be vary..
avgmarks=70
1. fail: if > 35 in any one subject
2. First division: if >=60
3. 2nd division: if avgmarks is between 50-59
4. 3rd divison: if avg marks is in between 35 to 49

so output form above command is

Result is: Fist division.



Review and complete these tasks before tomorrow class.


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

task4:
implement above program using 6 subjects.

task5:
Accept person's age display person status?

Step1: Design with o/p
----------------------

1. if age>=59
print senior citizen

2. if age is in between 25 to 57
- working citizen
3. if age is in between 16 and 24
- college students
4. if age is between 4-15
  - school kids
5. if kids are in between 1-3
  playing kids
6. invalid selection


o/p
---------------
Please enter your age:
user enters 59
sore 59 into a variable 'age' so age=50

print:
you are senior citizen.




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. ...