No Ubuntu, habilite o ssh para conectar e gerenciar o servidor remotamente: Como fazer

Depois de instalar o servidor ou desktop Ubuntu, você tem uma pergunta:O SSH está habilitado por padrão no Ubuntu? Então a resposta é absolutamente 'NÃO'. O usuário ou administrador deve instalar ou habilitar o SSH manualmente acionando apenas um comando de uma linha que mostraremos neste artigo. Mas antes disso vamos vero que é SSH?

OShell Seguro (SSH)é um protocolo que nos permite conectar o servidor ou desktop Ubuntu remotamente através de um canal seguro. Permite executar remotamente todos os comandos que podemos executar fisicamente no servidor. Até o usuário pode executar programas gráficos e de linha de comando, transferir arquivos e até mesmo criar redes privadas virtuais seguras pela Internet. É desenvolvido pelo Grupo de Trabalho de Rede da IETF e é um protocolo mais confiável que fornece segurança para sessões de login remoto e outros serviços de rede. SSH era originalmente um programa em um sistema UNIX e mais tarde foi rapidamente expandido para outras plataformas operacionais. O cliente SSH está disponível em diversas plataformas, incluindo Linux, Solaris, Windows, MacOS e outras.

Aqui informamos como habilitar o SSH no Ubuntu (18.04, 17.04, 16.04, 14.04…) ou Linux Mint.

  1. Abra oFinalização do comandol no servidor Ubuntu ou desktop.
  2. Para abrir o terminal de comando no modo gráfico o usuário pode usar o atalhoCTRL+ALT+T
  3. Faça login como usuário padrão ou root. Para root pode-se usarsudo -eu
  4. Execute o comando:sudo apt-get instalar ssh
  5. O comando acima instalará três pacotes:Cliente OpenSSH, servidor OpenSSH e servidor OpenSSH-SFTP.
  6. Uma vez queServidor SSH instalado, use este comando para habilitá-lo no Ubuntu:sudo serviço ssh iniciar
  7. Agora verifique o status do servidor SSH no Ubuntu usando:status ssh do serviço sudo

Se você deseja editar algumas configurações de SSH, como porta de escuta, permissão de login root e muito mais, isso pode ser feito editando o arquivo de configuração por meio deste comando:

sudo nano /etc/ssh/sshd_config

A saída de todos os comandos acima:

h2s@DESKTOP-N53EEI1:~$ sudo apt-get install ssh
[sudo] password for h2s:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgsoap-2.8.60 libvncserver1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
openssh-client openssh-server openssh-sftp-server
Suggested packages:
keychain libpam-ssh monkeysphere ssh-askpass molly-guard rssh
The following NEW packages will be installed:
ssh
The following packages will be upgraded:
openssh-client openssh-server openssh-sftp-server
3 upgraded, 1 newly installed, 0 to remove and 174 not upgraded.
Need to get 997 kB of archives.
After this operation, 106 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-sftp-server amd64 1:7.6p1-4ubuntu0.3 [45.6 kB]
Get:2 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-server amd64 1:7.6p1-4ubuntu0.3 [333 kB]
Get:3 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-client amd64 1:7.6p1-4ubuntu0.3 [614 kB]
Get:4 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ssh all 1:7.6p1-4ubuntu0.3 [5204 B]
Fetched 997 kB in 5s (197 kB/s)
Preconfiguring packages ...
(Reading database ... 99318 files and directories currently installed.)
Preparing to unpack .../openssh-sftp-server_1%3a7.6p1-4ubuntu0.3_amd64.deb ...
Unpacking openssh-sftp-server (1:7.6p1-4ubuntu0.3) over (1:7.6p1-4) ...
Preparing to unpack .../openssh-server_1%3a7.6p1-4ubuntu0.3_amd64.deb ...
Unpacking openssh-server (1:7.6p1-4ubuntu0.3) over (1:7.6p1-4) ...
Preparing to unpack .../openssh-client_1%3a7.6p1-4ubuntu0.3_amd64.deb ...
Unpacking openssh-client (1:7.6p1-4ubuntu0.3) over (1:7.6p1-4) ...
Selecting previously unselected package ssh.
Preparing to unpack .../ssh_1%3a7.6p1-4ubuntu0.3_all.deb ...
Unpacking ssh (1:7.6p1-4ubuntu0.3) ...
Processing triggers for ufw (0.35-5) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up openssh-client (1:7.6p1-4ubuntu0.3) ...
Setting up openssh-sftp-server (1:7.6p1-4ubuntu0.3) ...
Setting up openssh-server (1:7.6p1-4ubuntu0.3) ...
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:5AdbGb5TQhr0muu4hOz49gdBC8iRRqonYXv0s0JUUHE root@DESKTOP-N53EEI1 (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:m1ibvVu6wqieTG8Yd98ocAHv3X6XqYCuhx56zq7Jgzc root@DESKTOP-N53EEI1 (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:SF2xPgLXsCG1Z6yEF7/+wrqTxxptiyuimxgnC7XVpwc root@DESKTOP-N53EEI1 (ED25519)
invoke-rc.d: could not determine current runlevel
Setting up ssh (1:7.6p1-4ubuntu0.3) ...
h2s@DESKTOP-N53EEI1:~$ sudo service ssh status
* sshd is not running
h2s@DESKTOP-N53EEI1:~$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssh-server is already the newest version (1:7.6p1-4ubuntu0.3).
The following packages were automatically installed and are no longer required:
libgsoap-2.8.60 libvncserver1
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 174 not upgraded.
h2s@DESKTOP-N53EEI1:~$ sudo service ssh start
* Starting OpenBSD Secure Shell server sshd [ OK ]
h2s@DESKTOP-N53EEI1:~$ sudo service ssh status
* sshd is running
h2s@DESKTOP-N53EEI1:~$

Outros tutoriais úteis:

Related Posts