This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Exit on error | |
| set -e | |
| # Check if parameter is provided | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 <name>" | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Obtem o nome do grupo a ser perquisado | |
| getent group | cut -d":" -f1 | while IFS=: read -r groupname; do | |
| # Obtem o ID do groupo | |
| gid=$(cat /etc/group | grep ^"$groupname": | cut -d":" -f3) | |
| # Confere todos os usuários que utilizam o gropo | |
| used="false" | |
| for name in $(getent passwd | cut -d":" -f1); | |
| do | |
| is_member=$(id -G "$name" | grep "$gid") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Listar usuários | |
| getent passwd | |
| # Listar grupos | |
| getent group |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Crie as chaves pública e privadas para cada um dos | |
| # usuários com os seguintes procedimentos: | |
| # Verifique se a pasta .ssh existe para o usuário | |
| # que você deseja conceder o acesso SSH. | |
| ls -lah /home/<user>/ | |
| # [SE-NÃO] Cria a pasta e configure as permissões | |
| sudo mkdir –p /home/<user>/.ssh | |
| sudo chmod 700 /home/<user>/.ssh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Comece verificando os usuários & grupos pré-definidos em seu servidor. | |
| # O ideal é manter o minímo possível para ambos. Como essa é uma instalação | |
| # limpa, remova os usuários e grupos não necessários. | |
| # Obtém a listagem de usuários | |
| sudo getent passwd | |
| # Obtém a listagem de grupos | |
| sudo getent group | |
| # Com os usuários & grupos conferidos, vamos criar um novo grupo exclusivo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Atualize o servidor antes de começarmos | |
| sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade | |
| # Instale o pacote para realizar as atualizações automáticas | |
| sudo apt-get install unattended-upgrades | |
| # Mudamos para o diretório com as configurações | |
| cd /etc/apt/apt.conf.d | |
| # Editamos o arquivo de configuração principal |