User and Groups Administration
by Juan Manuel González Garzón
Common uses
I. User and groups basics
A. Adding a new user
#!/bin/sh
# Basic usage useradd:
# $ useradd [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa | rsa1] [-N new_passphrase] [-C comment] [-f output_keyfile]
# -q : Quiet
# The
# (-b 521 is the biggest value posible for ecdsa)
useradd juan
B. Set a password
#!/bin/sh
# Basic usage passwd:
# $ passwd [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
# -f: Forced mode, read more.
# -n: Do a dry-run. Print the keys that would have been installed
passwd juan
C. Password with stdin
#!/bin/sh
# Basic usage passwd:
# $ passwd [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
# -f: Forced mode, read more.
# -n: Do a dry-run. Print the keys that would have been installed
passwd juan
D. Create a new group
#!/bin/sh
# Basic usage groupadd:
# $ groupadd [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
# -f: Forced mode, read more.
# -n: Do a dry-run. Print the keys that would have been installed
groupadd familia
E. Add an user into a group
#!/bin/sh
# Basic usage usermod:
# $ usermod [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
# -f: Forced mode, read more.
# -n: Do a dry-run. Print the keys that would have been installed
usermod -aG familia juan
F. Review the groups of an user
#!/bin/sh
# Basic usage groups:
# $ groups [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
# -f: Forced mode, read more.
# -n: Do a dry-run. Print the keys that would have been installed
groups juan
II. Chage
chage -l juan
III. Locking Accounts
# Bring a folder from other machine
scp -r user@remote-ip-address:/home/other-user/Videos/testSCP/ Documents/
IV. Deleting Users
Example of SSH Tunneling and port forwarding
Reference
https://www.youtube.com/watch?v=z2DSNLJsdSw&list=PLXJyD2dL4oqeX-C3MvsMUJuEzWM4vLK2C