Wednesday, December 9, 2020

How to install and Use PSFTP – Putty’s SFTP Client


Go to - https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

And

Download - https://the.earth.li/~sgtatham/putty/latest/w64/psftp.exe

- Once the client is open. [PS: don't use root user, instead login as a normal user]


psftp: no hostname specified; use "open host.name" to connect

psftp> open root@192.168.119.144

Using username "root".

root@192.168.119.144's password:

Remote working directory is /root

psftp> dir

Listing directory /root

dr-xr-x---   17 root     root         4096 Dec  9 22:41 .

dr-xr-xr-x   21 root     root         4096 Nov 24 16:15 ..

-rw-------    1 root     root        22167 Dec 10 00:30 .bash_history

-rw-r--r--    1 root     root           18 Dec 29  2013 .bash_logout

-rw-r--r--    1 root     root          259 Dec  8 13:27 .bash_profile

-rw-r--r--    1 root     root          176 Dec  8 13:25 .bashrc

psftp: no hostname specified; use "open host.name" to connect

psftp> open root@192.168.119.144

Using username "root".

root@192.168.119.144's password:

Remote working directory is /root

psftp> dir

Listing directory /root

dr-xr-x---   17 root     root         4096 Dec  9 22:41 .

dr-xr-xr-x   21 root     root         4096 Nov 24 16:15 ..

-rw-------    1 root     root        22167 Dec 10 00:30 .bash_history

-rw-r--r--    1 root     root           18 Dec 29  2013 .bash_logout

-rw-r--r--    1 root     root          259 Dec  8 13:27 .bash_profile

-rw-r--r--    1 root     root          176 Dec  8 13:25 .bashrc

psftp: no hostname specified; use "open host.name" to connect

psftp> open root@192.168.119.144

Using username "root".

root@192.168.119.144's password:

Remote working directory is /root

psftp> lpwd

Current local directory is C:\Users\rajus\OneDrive\Documents\splunk

psftp> put fakedata.csv

local:fakedata.csv => remote:/root/fakedata.csv


psftp> ls

Listing directory /root

dr-xr-x---   17 root     root         4096 Dec 10 11:51 .

dr-xr-xr-x   21 root     root         4096 Nov 24 16:15 ..

-rw-------    1 root     root        22167 Dec 10 00:30 .bash_history

-rw-r--r--    1 root     root           18 Dec 29  2013 .bash_logout

-rw-r--r--    1 root     root          259 Dec  8 13:27 .bash_profile

-rw-r--r--    1 root     root          176 Dec  8 13:25 .bashrc

-rw-r--r--    1 root     root       127819 Dec 10 11:51 fakedata.csv

 Bash Auto completion package install and enable the completion feature.

Install the package with yum and source the bash_completion.sh and logout/login back.


yum install bash-completion bash-completion-extras
source /etc/profile.d/bash_completion.sh

Monday, December 7, 2020

How to change "which java" path to the desired Java version

- open .bash_profile and add the following to make java version as needed ( I needed this for jenkins and maven project as mvn install was failing from the ci_workflow job

 export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el7_9.x86_64

export PATH=$JAVA_HOME/bin:$PATH

- simply source the .bash_profile


[root@katello ~]# which java

/usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el7_9.x86_64/bin/java


[root@katello ~]# java -version
openjdk version "11.0.9" 2020-10-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)
[root@katello ~]# date
Tue Dec  8 12:28:18 IST 2020

 Installing maven and setting JAVA_HOME on CentOS7.


download binary tar.gz from - https://maven.apache.org/download.cgi

move it to /usr/local/src/

- Run below command to untar the file

# tar -xvzf apache-maven-3.6.3-bin.tar.gz

- Rename the default directory 

# mv apache-maven-3.6.3/ apache-mvn/

- Go to /etc/profile.d

# vi maven.sh

#!/bin/bash

# Apache Maven Environment Variables

# MAVEN_HOME for Maven 1 - M2_HOME for Maven 2

export M2_HOME=/usr/local/src//apache-mvn/

export PATH=${M2_HOME}/bin:${PATH}


- change the permission to executable

# chmod +x maven.sh

# source maven.sh

[root@katello ~]# mvn -version
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

Ran into this error - I had two versions of JDK installed jdk1.8.0_271-i586 and java-11-openjdk-11.0.9.11-0.el7_9.x86_64 

- Simply followed the JAVA_HOME to set to the latest Java version

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
#export JAVA_HOME=/usr/java/jdk1.8.0_271-i586
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el7_9.x86_64

- This fixed the issue.

[root@katello ~]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/src/apache-mvn
Java version: 11.0.9, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el7_9.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1127.19.1.el7.x86_64", arch: "amd64", family: "unix"
[root@katello ~]# date
Tue Dec  8 11:54:27 IST 2020

Friday, January 3, 2020

Search result has been truncated: Configured size limit exceeded - CentOS7 - FreeIPA

Ran into this error "Search result has been truncated: Configured size limit exceeded - CentOS7 - FreeIPA" while searching all hosts enrolled with FreeIPA - but the serach results were limited to 500 hosts, whereas our database had more than 800.

# ipa config-mod --searchrecordslimit=1000
# ipa host-find --all  | grep "Host name" > /tmp/ldap-all-hosts.txt