Friday, 2 December 2016

Password less authentication in linux

Source : host A
Destination: host B


1. Run the below command for generating public and private key( host A)

ssh-keygen -t rsa

/home/username/id_rsa (private key)
/home/username/id_rsa.pub (public key)

2. ssh-copy-id -i  /home/username/id_rsa.pub host_B_ip_address



Alternate way:

* Copy the text inside id_rsa.pub file .

* Login into host B and go to /root/username/

and create new file "authorized_keys" and paste text copied from step 2.

*  Login into Host A to Host B password less.(ssh host B)


Simple:

Put public key(host A) to authorized_keys(host B)

Now Host A can login into host B without any password.



Tuesday, 18 October 2016

ffmpeg merge audio video

ffmpeg merge audio video:

Input file : song.mp3 , video.mp4
Output file : output.mp4


ffmpeg -i song.mp3 -i video.mp4 -acodec copy -vcodec copy -f mp4 output.mp4


If your audio or video stream is longer, you can add the -shortest option so that ffmpeg will stop encoding once one file ends.

ffmpeg -i song.mp3 -i video.mp4 -acodec copy -vcodec copy -f mp4 -shortest output.mp4

Wednesday, 21 September 2016

Linux user management commands

Create user in linux :

root@test2:~# useradd test1
root@test2:~# passwd test1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Note : we can also create user with adduser command.

-Whenever user is created in linux the default access is assigned to user via /etc/profile file.
-Username is added to /etc/passwd file.
-Same as username one group is created in /etc/group file.
-Encrypted password save into /etc/shadow file.


Delete user in linux:

root@test2:~# userdel test1


Lock user account in linux:

root@test2:~# passwd -l test1
passwd: password expiry information changed.

when user will try to login he will get below message.

login as: test1
test1@192.168.0.10's password:
Access denied

When the user account is locked we can see ! sign after username in /etc/shadow file.

root@test2:~# cat /etc/shadow | grep test
test1:!$6$prWdpshs$A0WNBzbHC5sEke7hatNq8lFaB/Ux.SQ3vRc1.If4joDTD/AMpsuPYT.1mCmfBDUCoh6ND7izfcT9buo1wiZ581:17066:0:99999:7:::


Unlock user account in linux:

root@test2:~# passwd -u test1

passwd: password expiry information changed.

You can also unlock by editing /etc/sadow file. remove the ! sign from locked account.


Linux user account details :

root@test2:~# chage -l test1
Last password change                                    : Sep 22, 2016
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

See process run by user :

root@test2:~# ps  -u test1
  PID TTY          TIME CMD
 2442 ?        00:00:00 systemd
 2443 ?        00:00:00 (sd-pam)
 2463 ?        00:00:00 sshd
 2464 pts/0    00:00:00 sh

Root access to test1 user :

Edit the /etc/sudoers and add the below line.

%test1  ALL=(ALL:ALL) ALL

Switch to another user :

sudo su - username

root@test2:~# sudo su - test1
No directory, logging in with HOME=/
$ bash
test1@test2:/$