티스토리 뷰

IoT 과정

HPUX - Managing Users and Groups

gaelim 2017. 6. 26. 10:28
반응형

groups 

Every user on an HP-UX ystem is assigned a primary group membership and up to 20 additional group membership


# id user1

uid=301 (user1) gid=301(class)

#groups user1

class class2 users


HP-UX PAssword Mechanism

1 전통적 pw (default)

2 shadow pw

3 trusted system /tch/*


/etc/passwd File

Username :보통 8자, 그 이상도 가능하긴하지만 그 이상일 경우 명령어 사용시 짤림.

passwd 길이 : 8자

#passwd -l user1    //로그인할 수 없음

User ID, Group ID : 0 for root, 1-99 for system and 100~ for users. // 100: 영업부, 200: 생산부 이렇게 그룹화하여 사용함

Comment : 일반적으로 부서 전화번호 등을 적어둠, 관리자가 필요시 연락할 수 있음

Home Directory : user home directory

Command : Shell, /user/bin/sh, ksh, csh ...


password 변경

# vi /etc/passwd  // X

# vipw        // O


/etc/passwd 파일체크

#pwck


/etc/shadow File


username : username

password : when you convert to a shadowed system, each apssword in /etc/passwd is replaced with an "x", and the encrypted passwords are copied to the second filed in /etc/shadow


# ll /"directory name"

-rw-r--r--  1  root   root  ...  ...  


/data 에서 File을 저장시 UID, GID만을 저장한다. ll 사용시 userID 대신 username을 출력하는것은 /etc/passwd, GID대신 groupname을 출력하는것은 /etc/group 을 참조하는것이다. /etc/passwd 권한 이 r--r--r-- 인 것은 user, group외의 사람에게도 username groupname을 읽을 수 있게 편의상 되어있는 것이다.


보안이슈

악성 이용자가 /etc/passwd 그대로 뜰 수있다.

# perl -e "print crpyt('hp', 'xx')  xx : salt

- 결과와 /etc/passwd의 2번째 필드(password)와 비교하여 일치하는 것을 찾는 스크립트를 작성가능함


따라서 /etc/shadow file을 사용하게된다.


/etc/shadow (r--------)

UserName : 

Encrypted Password : /etc/passwd의 2번째필드와 같다

Last Changed : 계정 정보를 바꾼 날짜 1970.1.1부터 계산

Min Days : 강제적으로 password를 유지해야하는 일 수 

Max Days : 강제적으로 password를 바꿔야하는 일 수

Warn Days : 패스워드 만기되기까지(Max Days)의 경고 일 수 

Warn Days의 만기일과 Max Days의 만기일과 같다. Max Days가 끝나면 Inactive 상태로 간다

Inactive Days : 유휴계정을 유지할 수 있는 기간, 로그인 시 강제 비밀번호 바꿈을 수행하며 기간동안 로그인 하지 않을시 계정은 사용할 수 없게된다.


/etc/passwd 의 패스워드 필드를 shadow file로 옮기기

# pwconv 


you can revert to the traditional non-shadowed password functionality at any time via the pwunconv command

# pwunconv



/etc/group File

class::301:

class2::302:user1,user2,user3,user4,user5,user6,user7,user8,user9,user10,user11,user12,user13,user14,user15,user16,user17,user18,user19,user20,user21,user22,user23,user24


group name: groupID : group user


/etc/group 수정

# vi /etc/group 을 통해 한 경우

# grpck  을 통해 일관성 검정 할 수 있음


New files and directories that the user creates will, by default, be assigned to the user's primary group. Users who prefer to associate new files and directories with a secondary group can use the newgrp command to temporarily change their GID

# newgrp sales

To return to the primary group, run newgrp without any options

# newgrp


creating user accounts


# useradd 

-o : allow a duplicate UID

-u 101 : define the UID

-g users :define the primary group

-G class, training : define secondary groups

-c "student user" : define the comment field

-m -d /home/user1 : make(-m) a home directory(-d) for the user

-s /usr/bin/sh : define the default shell

-e 1/2/09 : define an account expiration date mm/dd/yy

-p fnnmD.DGyptLU : specify an encrypted password

-t /etc/default/useradd : specify a template

user1 : define the username


Interactively set a password for the new account

# passwd user1 : interactively specify a password 

# passwd -d user1 : set a null passwd

# passwd -f user1 : force a password change at a first login


Modify a user account

# usermod -l user01 user1 :

# usermod -o -u 101 user1  

# usermod -g users user1

# usermod -G class,trining user1

# usermod -c "student" user:cahnge ther user's comment field

# usermod -m -d /users/ .. 

# usermod -s /usr/bin/ksh user1 : change the user's default shell

# usermod -e 1/3/09 user1

# usermod -p finnmD.DGyptLU user1


Modify a user password

# passwd user1

$ chsh user1 /usr/bin/ksh : change the user's shell

$ chfn user1 : change the user's comment field


Deactivating User Accounts

# passwd -l user1 : lock user's password

Reactivating a user account

# passwd user1

Delete a user account, but leave the user's files untouched ( delete user1 from /etc/passwd ) 

# userdel user1

Remove a user's home directory

# rm -rf /home/user1 : recursively and force

Delete a user account and remove the user's home directory

# userdel -r user1


# find (조건) -exec (명령어) ;  : 조건을 만족할 때마다 명렁어를 수행

# find (조건) -exec (명령어)+  : 조건을 만족하는 것을 모아 한번에 명령 수행

Remove the user's files from every directory

# find / -user user1 -type f -exec rm -i +  : 루트 이하에서 user1의 file을 찾아 rm -i을 수행

# find / -user user1 -type d -exec rmdir + : 루트 이하에서 user의 dir을 찾아 rmdir을 수행

Transfer ownership to a different user

# find / -user user1 -exec chown user2 +

Find files owned by non-existent users or group

# find / -nouser -exec ll -d + : 루트 이하에서 nouser 소유의 디렉토리를 보여달라 

# find / -nogroup -exec ll -d +


Configuring password aging

# password -n 7 -x 70 -w 14 user1 : enales password aging for a user (min 7, warn 14, max 70)

Configuring Password Policies

# vi /etc/default/security 

MIN_PASSWORD_-LENGTH .. 등 수정하면가능함


Managing Groups

Create a new group

# groupadd -g 200 accts

Change a group name

# groupmod -n accounts accts

Add, modify, or delete a list of users to or from a group

# groupmod -a -l user1, user2 accounts : add a list of users to a group

# groupmod -m -l user3,user4 accounts : replace the list of users in a group

# groupmod -a -l user3,user4 accounts : delete a list of users from a group


Managing /etc/skel

~/.profile and other hidden files establish a user's environment at login

/etc/skel contains template files to be copied to every new user account


PS1 (shell prompt string), LPDEST (user's default printer), PATH (

EDITOR : Three variables must be defined if your users want to use command line editing

export EDITOR=vi

export HISTFILE=~/.sh_history

export HISTSIZE=50

EDITOR defines the user's preferred command line editor, emacs and vi are the only allowed values. HISTFILE determines the file that should be used to log commands entered by the user. HISTSIZE determines the number of commands the number of commands retained in the shell's command buffer.



반응형

'IoT 과정' 카테고리의 다른 글

Shell Scripting  (0) 2017.07.05
POSIX Shell Programming  (0) 2017.07.05
HPUX - Shell Programming - Loops  (0) 2017.06.23
HPUX - Shell Programming - Branches  (0) 2017.06.23
HPUX - Shell Programming  (0) 2017.06.23