Thursday, December 31, 2015

password and chown related notes

shadow passwords and pasword policy:::
password stored in /etc/shadow
to see that be root and cat /etc/shadow
[root@new-host-4 ~]# chage -l ashok
Last password change                                    : never
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

[root@new-host-4 ~]# chage -d 0 ashok      === will force to update password on the very next login attempt for the user.
chage -E yyyy-mm-dd   = set an expiry date for the password

ashok@192.168.10.9's password:
Last login: Wed Dec 30 22:41:11 2015 from 192.168.10.8
[ashok@new-host-4 ~]$ /etc/shadow
-bash: /etc/shadow: Permission denied
[ashok@new-host-4 ~]$ sudo /etc/shadow
[sudo] password for ashok:
sudo: /etc/shadow: command not found
[ashok@new-host-4 ~]$ /etc/shadow
-bash: /etc/shadow: Permission denied
[ashok@new-host-4 ~]$ su -
Password:
Last login: Wed Dec 30 22:46:39 EST 2015 on pts/0
[root@new-host-4 ~]# cat /etc/shadow
root:$6$1ZLgIZk9$b356o6XdyONjLO6gM73ZiUJ9PMca28vWSHfOMTCLPYsJC9PZEXarB01OVT2VgDyK9DHriCveHWTCL3XlIXo7.1:16799:0:99999:7:::
bin:*:16659:0:99999:7:::
daemon:*:16659:0:99999:7:::
adm:*:16659:0:99999:7:::
lp:*:16659:0:99999:7:::
sync:*:16659:0:99999:7:::
shutdown:*:16659:0:99999:7:::
halt:*:16659:0:99999:7:::
mail:*:16659:0:99999:7:::
operator:*:16659:0:99999:7:::
games:*:16659:0:99999:7:::
ftp:*:16659:0:99999:7:::
nobody:*:16659:0:99999:7:::
avahi-autoipd:!!:16796::::::
systemd-bus-proxy:!!:16796::::::
systemd-network:!!:16796::::::
dbus:!!:16796::::::
polkitd:!!:16796::::::
tss:!!:16796::::::
postfix:!!:16796::::::
sshd:!!:16796::::::
ashok:$6$PbsfPTSy00gDE9.i$vyENBhp7zuQbrA820n0WRNrtpnCUEOTNl9sxrkVZcdVGDCDpaiD0puWUcYatHP8R3dqxaeUADJZHzqcdg.s441::0:99999:7:::
devi:$6$zMZ78S9l$8FVniuXvTtkpPTl8Me6VVUEXdnkdqABIh2FdVB5I/ZuUtrXkrKgdNgJf5s6LGVv4kA.9dm4.NvRz//zUCd3Wd/:16800:0:99999:7:::
geoclue:!!:16797::::::
usbmuxd:!!:16797::::::
libstoragemgmt:!!:16797::::::
rpc:!!:16797:0:99999:7:::
unbound:!!:16797::::::
rtkit:!!:16797::::::
chrony:!!:16797::::::
colord:!!:16797::::::
abrt:!!:16797::::::
saslauth:!!:16797::::::
setroubleshoot:!!:16797::::::
qemu:!!:16797::::::
radvd:!!:16797::::::
pulse:!!:16797::::::
rpcuser:!!:16797::::::
nfsnobody:!!:16797::::::
gdm:!!:16797::::::
gnome-initial-setup:!!:16797::::::
avahi:!!:16797::::::
ntp:!!:16797::::::
tcpdump:!!:16797::::::
kamal:$6$FyCVh1Kq$6u5H8sG6F7P8v.vruuES2up8l.behwzseIWwdmD1nqy8A.WA7wT0gay/X5VMyGqIAaATtXn4VXA4Usy6C9SP4/:16798:0:99999:7:::
sachin:$6$guWE/XTA$xOrtQofhj/5mCBWH025bdmLhNRyumrui4Kr5T.x3cxqL0/rT53U0GZu6x7I4ajrpeDlTMVVfSHuGZxjG2v.hm.:16799:0:99999:7:::
hari:!!:16799:0:99999:7:::
jullet:$6$PEFa96HD$Bm91uVhEtutf4KexUxqbsp8IFiahpSjdApYFyi2wRFkZwlA5HNognyD.cOjb02gebaYfJUPeOVyqkXKxSzMUK/:16799:0:99999:7:::
romeo:$6$D1.VS6ys$/O7buiTC7O0NWEBd.ozT5lIcYByJ9ICFK1eZq7dWF0JUhpp6jC9m4VjHVL9lxpUUFan1w16dtzds2ONEmZEL6.:16799:0:99999:7:::
hamlet:$6$zz7JYbWS$Ga.a9eLlOE9hAybd.p2slgBFH0PtDY64UDb5tC6YNE1M10PLRn338bjgwPkC5juSBPHHaph/W0peBOQQtq3Ww/:16799:0:99999:7:::
dolly:$6$y.9RDJ6j$k9zR8XeZyi8.3CLLTkklD1gnEJDaY1Mf.RtgHO4yUE2IrH9R2jwLqRfnxwrcPh/QpWw/vreYWZdWsGucSnzwN/:16799:0:99999:7:::
elvis:$6$FTyDcxr9$19dToz5zVGCBIPm7BlFsRwEUeOgnBMMXKIq/rKPnnROB4uIFN9rPIE29RwMgQ41NDa9irQEdUqokErl7UvgAc1:16799:0:99999:7:::
reba:$6$Rs9g8bWS$v6cGYROGlSxbBVvHhtsqC0A2IWGmYJEdIOMPQ2WrmcW2.7WsaR.kdVh.D1ys42vp2XjTW5PBKTSjf8QLGoSEK0:16799:0:99999:7:::
amrit:!!:16799:0:99999:7:::
apache:!!:16800::::::
[root@new-host-4 ~]# chage -l ashok
Last password change                                    : never
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

[root@new-host-4 ~]# chage -d 0 ashok
[root@new-host-4 ~]# useradd hari
useradd: user 'hari' already exists
[root@new-host-4 ~]# useradd sita
[root@new-host-4 ~]# usermod -L sita
[root@new-host-4 ~]# su sita
[sita@new-host-4 root]$ man usermod
[sita@new-host-4 root]$
[sita@new-host-4 root]$ usermod -L -e 1 sita
bash: /sbin/usermod: Permission denied
[sita@new-host-4 root]$ su root
Password:
[root@new-host-4 ~]# usermod -L -e 1 sita
[root@new-host-4 ~]# su - sita
Last login: Thu Dec 31 00:34:29 EST 2015 on pts/0
[sita@new-host-4 ~]$ id sita
uid=1235(sita) gid=1235(sita) groups=1235(sita)
[sita@new-host-4 ~]$ usermod -U sita
-bash: /usr/sbin/usermod: Permission denied
[sita@new-host-4 ~]$ su root
Password:
[root@new-host-4 sita]# useradd harry


[root@new-host-4 sita]# usermod -s /sbin/nologin harry
[root@new-host-4 sita]# su harry
This account is currently not available.

to require a password  change every 90 days

[ashok@new-host-4 ~]$ sudo chage -M 90 romeo
[sudo] password for ashok:
[ashok@new-host-4 ~]$ man chage
[ashok@new-host-4 ~]$ sudo chage -l romeo
Last password change                                    : Dec 30, 2015
Password expires                                        : Mar 29, 2016
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 90
Number of days of warning before password expires       : 7

force the password change on the first login for the any account
sudo chage -d 0 romeo
to set a expiry date on future:::
  first of all get what date is that::
  date -d "+180 days" then
  sudo chage -E 2016-08-03 expires on this date on future
   sudo vi /etc/login.defs(password stored in /etc/login.defs
   kamal@192.168.10.9's password:
Last login: Thu Dec 31 09:43:32 2015
[kamal@new-host-4 ~]$ passwd ashok
passwd: Only root can specify a user name.
[kamal@new-host-4 ~]$ root
bash: root: command not found...
[kamal@new-host-4 ~]$ su -
Password:
Last login: Thu Dec 31 00:45:01 EST 2015 on pts/0
Last failed login: Thu Dec 31 01:02:53 EST 2015 on pts/1
There were 2 failed login attempts since the last successful login.
[root@new-host-4 ~]# passwd
Changing password for user root.
New password:
Password change aborted.
New password:
Password change aborted.
New password:
[root@new-host-4 ~]# passwd ashok
Changing password for user ashok.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
[root@new-host-4 ~]# su ashok
[ashok@new-host-4 root]$ cd
[ashok@new-host-4 ~]$ sudo chage -M 90 romeo
[sudo] password for ashok:
[ashok@new-host-4 ~]$ man chage
[ashok@new-host-4 ~]$ sudo chage -l romeo
Last password change                                    : Dec 30, 2015
Password expires                                        : Mar 29, 2016
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 90
Number of days of warning before password expires       : 7
[
[ashok@new-host-4 ~]$ sudo vi /etc/login.defs( passwd login details of all users paswd change and many more)

using chown to change the ownership of the file for eg here a file called foofiles is created by root user and using chown changed to kamaluser
[root@new-host-4 ~]# touch foofiles
[root@new-host-4 ~]# ls -l foofiles
-rw-r--r--. 1 root root 0 Dec 31 10:29 foofiles
[root@new-host-4 ~]# chown kamal foofiles
[root@new-host-4 ~]# ls -l foofiles
-rw-r--r--. 1 kamal root 0 Dec 31 10:29 foofiles
chown -R performs recusrsive change of ownership includiong directories and  its conteent



[sudo] password for ashok:
sudo: vim/etc/login.defs: command not found
[ashok@new-host-4 ~]$ which etc
/usr/bin/which: no etc in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[ashok@new-host-4 ~]$ man which
[ashok@new-host-4 ~]$ sudo vim/etc/login.defs
sudo: vim/etc/login.defs: command not found
[ashok@new-host-4 ~]$ sudo vi /etc/login.defs
[ashok@new-host-4 ~]$ ^C
[ashok@new-host-4 ~]$ groupadd -g
bash: /sbin/groupadd: Permission denied
[ashok@new-host-4 ~]$ sudo groupadd -g 4000 consultants
[ashok@new-host-4 ~]$ tail -f /etc/group
apache:x:48:
abc:x:1451:ashok
abcd:x:5001:ashok
wheel:x:10:ashok,kamal
addd:x:5002:
shakespeare:x:3000:jullet,romeo,hamlet
artists:x:5003:reba,dolly,elvis
sita:x:1235:
harry:x:1236:
consultants:x:4000:
^C
[ashok@new-host-4 ~]$ sudo useradd -G consulatants sspade
useradd: group 'consulatants' does not exist
[ashok@new-host-4 ~]$ sudo useradd -G consultants sspade
[ashok@new-host-4 ~]$ sudo useradd -G consultants bboop
[ashok@new-host-4 ~]$ sudo useradd -G consultants dtracy
[ashok@new-host-4 ~]$ tail -5 /etc/group
harry:x:1236:
consultants:x:4000:sspade,bboop,dtracy
sspade:x:1237:
bboop:x:1238:
dtracy:x:1239:
[ashok@new-host-4 ~]$ passwd sspade
passwd: Only root can specify a user name.
[ashok@new-host-4 ~]$ sudo passwd sspade

passwd: Unknown user name 'dtrac'.
[ashok@new-host-4 ~]$ sudo passwd dtracy
Changing password for user dtracy.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
Sorry, passwords do not match.
New password:
Retype new password:
Sorry, passwords do not match.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
Sorry, passwords do not match.
passwd: Have exhausted maximum number of retries for service
[ashok@new-host-4 ~]$ passwd dtracy
passwd: Only root can specify a user name.
[ashok@new-host-4 ~]$ sudo passwd dtracy
Changing password for user dtracy.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
[ashok@new-host-4 ~]$ sudo chage -d 0 dtracy
[ashok@new-host-4 ~]$ lab localusers grade
bash: lab: command not found...
[ashok@new-host-4 ~]$



No comments:

Post a Comment