$ vim user_input.py
roll_num = int(input("Enter your roll no.:"))
message = "Hello user your roll number is " + str(roll_num)
print(message)
:x
or
$ vim user_input.py
roll_num = int(input("Enter your roll no.:"))
print("Hello user your roll number is " + str(roll_num))
:x
$ python user_input.py
output "rds_endpoint" { value = "${aws_db_instance.myinstance.endpoint}" }
save and exit $ terraform init $ terraform plan $ terraform apply -auto-approve install mysql client in local host $ sudo apt install mysql-client To access the mysql $ mysql -h <end_point_URL> -P 3306 -u <username> -p To destroy the mysql RDS instance $ terraform destroy -auto-approve
create directory s3-demo and navigate $ mkdir s3-demo && cd s3-demo create a demo file sample.txt andβcontents $ echo βthis is sample object to store in demo-bucketβ > sample.txt create main.tf file $ vim main.tf
Install AWS CLI $ sudo apt install awscli -y
To check for the version $ aws βversion
To configure AWS account crdentials
copy the access and secret key from AWS account security credentials $ aws configure
AWS Access Key ID [None]: *****************Β
AWS Secret Access Key [None]: ******************
Default region name [None]: ap-south-1
Default output format [None]: json or table or text
output "public_ip" { description = "public ip of the instance" value = aws_instance.app_server.public_ip }
save and exit initialize the terraform $ terraform init $ terraform plan $ terraform apply -auto-approve it will create the AWS EC2 instance with output the public ip of the instance
To destroy the instance $ terraform destroy -auto-approve
To create postgres DB $ aws rds create-db-instance --db-instance-identifier demo-postgresql --db-instance-class db.t3.micro --engine postgres --master-username postgres --master-user-password passcode123 --allocated-storage 20
To describe and get the endpoint url $ aws rds describe-db-instances --db-instance-identifier demo-postgresql | grep Address
To access the remote postgresql $ psql --host=<endpoint_url> --port=5432 --username=postgres --dbname=postgres --password
To delete the db instance without final snapshot and automated backups $ aws rds delete-db-instance --db-instance-identifier demo-postgresql --skip-final-snapshot --delete-automated-backups
To create a mysql db $ aws rds create-db-instance --db-instance-identifier demo-mysql --db-instance-class db.t3.micro --engine mysql --master-username admin --master-user-password passcode123 --allocated-storage 20
To describe and get the endpoint url $ aws rds describe-db-instances --db-instance-identifier demo-mysql | grep Address
To access the remote mysql DB $ mysql -h <endpoint_url> -P 3306 -u admin -p
To delete the db instance without final snapshot and automated backups $ aws rds delete-db-instance --db-instance-identifier demo-mysql --skip-final-snapshot --delete-automated-backups
choose the EBS volume and click modify
give the desired size to extend the volume
in Linux terminal umount the volume $ sudo umount /dataΒ (where the ebs volume is mounted) $ sudo e2fsck -f /dev/xvdf $ sudo resize2fs /dev/xvdf
mount the volume again $ sudo mount -a $ df -Th
stop the freeradius service # systemctl stop freeradius.service
To run FreeRADIUS debug mode # freeradius -X
login to mariadb and create DB , DB user and password # mysql -u root > CREATE DATABASE radius; > GRANT ALL ON radius.* TO radius@localhost IDENTIFIED BY "PASSWORD"; > FLUSH PRIVILEGES; > QUIT;
check the DB created # mysql -u root -p -e "show databases;"
download the daloradius webGUI package from github # wget https://github.com/lirantal/daloradius/archive/refs/tags/1.3.zip
extract the package # unzip 1.3.zip
rename the folder mv daloradius-1.3/ daloradius
To populate the database with the daloRADIUS schema. The .sql file is located in the β/contrib/db/β folder.
we might have to change this path if you didnβt install it in the root destination. # mysql -u root -p radius < contrib/db/fr2-mysql-daloradius-and-freeradius.sql # mysql -u root -p radius < contrib/db/mysql-daloradius.sql
move the daloradius folder to /var/www/html # mv daloradius /var/www/html/
rename the daloradius.conf.php.sample to daloradius.conf.php # mv /var/www/html/daloradius/library/daloradius.conf.php.sample /var/www/html/daloradius/library/daloradius.conf.php
assign ownership of the daloRADIUS web configuration files to Apache # chown -R www-data:www-data /var/www/html/daloradius/
configure the permissions of main configuration file to 664 # chmod 664 /var/www/html/daloradius/library/daloradius.conf.php
To allow the DaloRADIUS web interface to access FreeRADIUS,
to provide its database details in the configuration file for DaloRADIUS
add the database details(username, password and db name)
in the below file # vim /var/www/html/daloradius/library/daloradius.conf.php
restart the freeradius and apache2 and check the status # systemctl restart freeradius # systemctl restart apache2 # systemctl status freeradius # systemctl status apache2
access the daloradius http://ip-address/daloradius/login.php
default username : administrator
default password : radius To change the default password config > operators > list operators > administrator > operator password and apply
For example to encrypt the password for
mysql_secure_installation using shell script
install these packages $ sudo apt install sshpass gnupg2
create a file $ touch .secrets $ cat > .secrets passcode123 ^D
Encrypting Your Password $ gpg -c .secrets
it will create a file with .secrets.gpg
to decrypt $ gpg -dq .secrets.gpg
create the mariadb secure installation script $ cat mariadb.sh #!/bin/bash
apt install mariadb-server mariadb-client -y
systemctl enable mariadb.service
mysql_secure_installation <<EOF
y
n
y
gpg -dq secrets.gpg | sshpass
gpg -dq secrets.gpg | sshpass
y
y
y
y
EOF
:wq! save and exit