Setting grub password in single line command

as grub  does not accept the password in single linewith below method.

[root@host1~]# echo -e “password\npassword” | grub2-setpassword
stty: standard input: Inappropriate ioctl for device

we can use below command to reset the grub password(but it ask for manual intervention)

printf '%s\n' "password" "password" | script -qf -c 'grub2-setpassword' /dev/null

save the above command to grub-pass.sh and run with nohup  command

 

 

Server hardening linux

Server harding is a process to make system secure and manageable.

for example.

  1. root login disable on ssh
  2. set password in single usermode
  3. removing unwanted kernal module
  4. enforcing SELinux
  5. remote login warning banner
  6. apply security patches
  7. Disable xinetd service
  8. unwanted network port blocked
  9. Enable audit logs
  10. logging is configured

Steps for hardening : https://www.cisecurity.org/cis-benchmarks/

mysql master slave sync

mysql master =  192.168.0.10

vi /etc/my.cnf

#added for master sync
log-bin
server_id=1

CREATE USER ‘slaveuser’@’%’ IDENTIFIED BY ‘password’;
GRANT REPLICATION SLAVE ON *.* TO ‘slaveuser’@’%’;

FLUSH TABLES WITH READ LOCK;

mysqldump -A > alldb.sql

scp alldb.sql 192.168.0.11:/root

SHOW MASTER STATUS;

UNLOCK TABLES;

mysql slave = 192.168.0.11

mysql -u root < /root/alldb.sql

CHANGE MASTER TO
MASTER_HOST=’192.168.0.10′,
MASTER_USER=’slaveuser’,
MASTER_PASSWORD=’password’,
MASTER_PORT=3306,
MASTER_LOG_FILE=’mariadb-bin.000001′,
MASTER_LOG_POS=2024361,
MASTER_CONNECT_RETRY=10;

START SLAVE;

SHOW SLAVE STATUS \G