Translate

Tuesday, June 10, 2014

Change Linux port and Security

1. Configure ssh to login via port 2243 and disable direct root access to the server.

Check port 2243 allready in use
vi /etc/services  and search port number
Open /etc/ssh/sshd_config and change below lines
Port 2243
PermitRootLogin no

2. Configure iptables in the machine and block port 22 to deny ssh access from 192.168.1.9

iptables -A INPUT -p tcp --dport 2243 -s 192.168.1.42 -j REJECT

Reset MySQL root password.

1. Reset the password for mysql root user to 'linux123'.

service mysqld stop
mysqld_safe --skip-grant-tables &
mysql -u root
update mysql.user set password=PASSWORD("linux123") where User='root';
flush privileges;
exit;
service mysqld stop
service mysqld start

2. Make sure you login directly to the mysql console by typing in 'mysql' in konsole.

create a file "  /root/.my.cnf "
[client]
user="root'
password="linux123"

3. Find a way to backup all database in the server at once.

./mysqldump --all-databases > /root/backup/all.sql

MySQL commands

1. Create a database named "linux".

create database <database name>

eg: create database linux;

2. CREATE TABLE named employee_data with coulumns emp_id , name, designation,
age,email address.

create table employee_data(emp_id int(10),name varchar(40),designation
varchar(40),age int(3),emailaddress varchar(50));

3. Enter atleast 10 entries to this table.

insert into employee_data values ('1','joy','linuxadmin','24','abc@gmail.com');

4. take a backup of this database.

./mysqldump -u {user name} -p {database name} > patht/backupname.sql

eg: ./mysqldump -u user -p linux > /root/backup/linux.sql (Note: you can specify any path)