- Delete home directory
deluser --remove-home $USER
http://unix.stackexchange.com/questions/289590/cant-add-user-because-group-already-exists
adduser --ingroup $USER $USER
cut -d: -f1 /etc/passwd
/var/log/*
/var/log/auth.log
/etc/passwd
/etc/ssh/ssh_config
/etc/ssh/sshd_config
sudo chmod 700 .ssh && sudo chmod 600 .ssh/authorized_keys
- Note: The home directory must not be group writable, .ssh must not be group readable, and auth_keys cannot be group readable or executable at all in order for the public key auth to work.
- Have
ServerAliveInterval 60
in clients/etc/ssh/ssh_config
cat ~/.ssh/id_rsa.pub | user@ip "cat >> ~/.ssh/authorized_keys"
- Good examples of SGID here: http://www.linuxnix.com/sgid-set-sgid-linuxunix/
- Change permissions to RWX for everyone, recursively
chmod 777 -R folder/file
- Change permissions to RWX for owner, RW for group and all
chmod 755 folder/file
- Change permissions to RWX for owner, RWX for group, RW for all, but only the file/folder owner can delete
- Set a sticky bit using 4 digits
chmod 1775 -R folder/file
- File can still be emptied however, this is mainly to prevent an accidental
rm -rf
on a directory - One thing to note as well, you can open the file as appendable only:
- http://stackoverflow.com/a/869565 You can use 'chattr +a' which means "file can only be opened in append mode for writing", meaning you can't rewrite existing content, but you can add new content to the end. This should prevent truncation.
- Set the GID bit on a file/directory so any file/directory accessed/created within it, uses the same group id
chmod g+s -R folder/file
- Set the UID bit on a file/directory so any file/directory accessed/created within it, uses the same user id
chmod u+s -R folder/file
- Change ownership to
userA:groupA
, recursivelychown userA:groupA -R folder/file
- Change shell for user
chsh userA -s /usr/bin/git-shell
- Rsync and change user/group and permissions to RWX for owner, RW for group and all
rsync -avuz --chown=user:group --chown=755 srcfile destfile
- Zip all files and directores in current folder into
data.zip
zip -r data *
- Unzip into director
mydir
unzip pics.zip -d /path/to/mydir
- Prepends
addkey
, quotes the ssh-key, and passes to ssh. Result is:addkey "ssh-key dawdawd"
echo "addkey \"$(cat ~/.ssh/id_rsa.pub)\"" | ssh user@ip
- Allow all port connections from specific ip
ufw allow from my.ip.addr.here
- Allow connections from specific ip to specific port
ufw allow to any port PORTNUM from my.ip.addr.here
- Allow all ips to specific port/protocol
ufw allow to any port 80 proto tcp