Ir ao conteúdo

Instalar e deixar seu servidor SSH mais seguro.

Boa noite,

Estou com umas idéias de coisas que planejo “desenvolver” para navegar de maneira mais segura. Como precisarei do SSH, acesso a portas das máquinas virtuais e coisas assim estou fazendo posts relacionados a estes assuntos já que precisarei dos mesmos para “desenvolver” tal segurança. E assim, o futuro post não ficará tão extenso.

Para você instalar o ssh-server no Ubuntu é muito simples:
$ sudo apt-get install openssh-server

Após isso você deve fazer algumas modificações para ficar mais seguro. Acesse o arquivo /etc/ssh/sshd_config
$ sudo vi /etc/ssh/sshd_config

AllowUsers USUARIO #habilita somente este usuario
AllowGroups GRUPO_DO_USUARIO # habilita somente este grupo
PasswordAuthentication yes
MaxStartups 2:100:2
Port XXX # Alguma porta aleatoria de sua vontade que não esteja em uso.

O que o MaxStartups faz? Especifica o número máximo de conexões não autenticadas ao servidor. Sua sintaxe é a seguinte inicio:porcentagem:maximo. Vamos supor, inicio = 10, porcentagem = 50, maximo = 20. Quando for atingidas 10 conexões ele irá iniciar com a porcentagem, ou seja, uma conexão terá chance de ser fechada de cara ou não, a mesma aumenta linearmente até o número máximo de conexões, e apartir dessa todas são negadas. Eu particularmente pensei um pouco e decidi adotar o inicio com 2, porcentagem com 100 e máximo como 2 então qualquer nova conexão apartir de 2 será automaticamente recusada. (Isso pode ser um problema caso existam pessoas tentando invadir seu servidor e provavelmente estarão utilizando todas as sessões). Talvez o recomendavel seja mais correto 10:30:60 porém prefiro deixar o meu mais restrito.
/etc/init.d/ssh

Você ainda pode adicionar o seguinte código ao /home/usuario/.profile:

echo Digite sua senha de segurança:
read senha
if [ $senha == “SUA_SENHA” ]
then
# CÓDIGOS QUE JÁ ESTÃO NO PROFILE!
else
exit
fi

Não se esqueça de bloquear acesso do root

Na minha máquina também desabilitei o comando “su” da seguinte maneira:
$ chmod 700 /usr/bin/su-to-root

Grato,
Matheus

Referencias:
Desabilitar Comando SU
Informação MaxStartups

Duas dicas que não são relacionadas com segurança, você pode descomentar a linha

Banner /etc/arquivo # Default /etc/issue.net

A mensagem que está dentro do /etc/arquivo irá ser exibida quando se conectar no SSH.

Para editar a mensagem que apareça assim que o usuario se loga você deve editar o /etc/motd.

Publicado emLinuxShell Script

159 Comentários

  1. I am not sure where you are getting your info, but great topic. I needs to spend some time learning more or understanding more. Thanks for great info I was looking for this information for my mission.

  2. Whoa! This blog looks just like my old one! It’s on a entirely different subject but it has pretty much the same page layout and design. Excellent choice of colors!

  3. DichaelTiemi DichaelTiemi

    Hi there I am so happy I found your webpage, I really found you by error, while I was looking on Askjeeve for something else, Regardless I am here now and would just like to say kudos for a tremendous post and a all round entertaining blog (I also love the theme/design), I don’t have time to browse it all at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the superb jo.
    Watch sexual porno video xxx sex adults site

  4. https://888starz.net.co/
    888Starz Colombia es una plataforma de casino online y casa de apuestas que reune mas de 9.500 juegos, abarcando maquinas tragamonedas, ruletas y mesas con croupier real y una completa cobertura de eventos deportivos que abarca desde la Liga BetPlay hasta la Champions League y esports.

  5. Stephenunurn Stephenunurn

    Right here is the right webpage for anybody who wishes to understand this topic. You realize a whole lot its almost tough to argue with you (not that I actually would want to…HaHa). You definitely put a brand new spin on a subject that has been discussed for many years. Excellent stuff, just wonderful!
    Xxx video onlyfans sex video site

  6. EarnestCot EarnestCot

    I think that what you wrote made a lot of sense. However, consider this, what if you wrote a catchier post title? I mean, I don’t wish to tell you how to run your blog, however suppose you added something that grabbed a person’s attention? I mean %BLOG_TITLE% is a little plain. You ought to glance at Yahoo’s front page and watch how they create news titles to grab viewers to open the links. You might add a video or a picture or two to get people interested about everything’ve written. Just my opinion, it might bring your posts a little livelier.
    Timothy Malmros Genach

  7. LewisJonus LewisJonus

    Good day I am so thrilled I found your webpage, I really found you by error, while I was browsing on Askjeeve for something else, Anyhow I am here now and would just like to say cheers for a remarkable post and a all round interesting blog (I also love the theme/design), I don’t have time to read it all at the minute but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the awesome b.
    https://ital-parts.com.ua/chomu-na-santa-fe-shvydko-zhovtiie-korpus.html

  8. Casino vavada zyskuje pozytywne opinie dzięki różnorodnej ofercie obejmującej sloty, gry stołowe oraz turnieje z evolution gaming. Kasyno online oferuje bonus powitalny, darmowe spiny i bonusy oraz kody promocyjne dla nowych graczy. Obsługa klienta gaming działa sprawnie, a gracze mogą wziąć udział w promocjach dostępnych na vavada pl.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *