Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Problema na instalação do SSH?

Prezados, utilizo o Ubuntu 20.04.1, instalado exclusivamente para realizar alguns dos cursos.

Na instalação do ssh tive os seguintes logs:

acrajag@acrajag-ZenBook-UX481FL-UX481FL:~/Downloads$ sudo apt-get install ssh
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  ncurses-term openssh-server openssh-sftp-server ssh-import-id
Suggested packages:
  molly-guard monkeysphere ssh-askpass
The following NEW packages will be installed:
  ncurses-term openssh-server openssh-sftp-server ssh ssh-import-id
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 693 kB of archives.
After this operation, 6130 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://pt.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.1 [51,5 kB]
Get:2 http://pt.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.1 [377 kB]
Get:3 http://pt.archive.ubuntu.com/ubuntu focal-updates/main amd64 ssh all 1:8.2p1-4ubuntu0.1 [5080 B]
Get:4 http://pt.archive.ubuntu.com/ubuntu focal/main amd64 ncurses-term all 6.2-0ubuntu2 [249 kB]
Get:5 http://pt.archive.ubuntu.com/ubuntu focal/main amd64 ssh-import-id all 5.10-0ubuntu1 [10,0 kB]
Fetched 693 kB in 0s (1905 kB/s)          
Preconfiguring packages ...
Selecting previously unselected package openssh-sftp-server.
(Reading database ... 258140 files and directories currently installed.)
Preparing to unpack .../openssh-sftp-server_1%3a8.2p1-4ubuntu0.1_amd64.deb ...
Unpacking openssh-sftp-server (1:8.2p1-4ubuntu0.1) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a8.2p1-4ubuntu0.1_amd64.deb ...
Unpacking openssh-server (1:8.2p1-4ubuntu0.1) ...
Selecting previously unselected package ssh.
Preparing to unpack .../ssh_1%3a8.2p1-4ubuntu0.1_all.deb ...
Unpacking ssh (1:8.2p1-4ubuntu0.1) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../ncurses-term_6.2-0ubuntu2_all.deb ...
Unpacking ncurses-term (6.2-0ubuntu2) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_5.10-0ubuntu1_all.deb ...
Unpacking ssh-import-id (5.10-0ubuntu1) ...
Setting up openssh-sftp-server (1:8.2p1-4ubuntu0.1) ...
Setting up openssh-server (1:8.2p1-4ubuntu0.1) ...

Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...
3072 SHA256:PXgigx4wYfkz7MFAlZF4LiuMcsiI7dC6/jFoMbe730I root@acrajag-ZenBook-UX481FL-UX481FL (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:ioQ2skuw9aluI3rjDCBLSVMtnwnmuCsyctRvSxM7sF0 root@acrajag-ZenBook-UX481FL-UX481FL (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:IEzTm3VcWfa5DLxaj4zSXHO4FNFQqEgE+YLJD51jDbk root@acrajag-ZenBook-UX481FL-UX481FL (ED25519)
Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.
Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service.
/usr/sbin/policy-rc.d returned 101, not running 'start rescue-ssh.target'
invoke-rc.d: policy-rc.d denied execution of start.
Setting up ssh-import-id (5.10-0ubuntu1) ...
Attempting to convert /etc/ssh/ssh_import_id
Setting up ncurses-term (6.2-0ubuntu2) ...
Setting up ssh (1:8.2p1-4ubuntu0.1) ...
Processing triggers for systemd (245.4-4ubuntu3.4) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for ufw (0.36-6) ...

Peço atenção ao final, onde se vê:

/usr/sbin/policy-rc.d returned 101, not running 'start rescue-ssh.target'
invoke-rc.d: policy-rc.d denied execution of start.

Ao tentar conectar ao outro usuário, retorna o seguinte?

acrajag@acrajag-ZenBook-UX481FL-UX481FL:~$ ssh test@localhost
ssh: connect to host localhost port 22: Connection refused

O mesmo ocorre na tentaviva de copiar os arquivos:

acrajag@acrajag-ZenBook-UX481FL-UX481FL:~/Desktop/workspace$ scp bemvindo2.txt jose@localhost:~/
ssh: connect to host localhost port 22: Connection refused
lost connection

Preciso de ajuda, porque a utilização do Ubuntu está deprimente! Instalei para estudar DevOps, especificamente para o Ansible e Docker, mas seguindo toda a formação. Por ter problemas nas instalações resolvi vir para o curso de Linux antes, mas tenho os mesmos problemas aqui a partir da aula 9 deste segundo módulo (APT). Como podem ver, há pedido de ajuda em cada um dos tópicos a partir da aula 9.

Peço ajuda para compreender o que pode estar causando este problema e poder concluir o curso.

Obrigado.

3 respostas

Olá, André. Tudo bem?

Você executar o comando ss -lntppara a gente ver se o servidor ssh foi inciado com sucesso? Se sim, aparecerá algo do tipo:

State                    Recv-Q                   Send-Q                                     Local Address:Port                                     Peer Address:Port                  Process
LISTEN                   0                        128                                              0.0.0.0:22                                            0.0.0.0:*
LISTEN                   0                        128                                                 [::]:22                                               [::]:*

Se não houver uma saída mostrando a porta padrão usada pelo ssh (22) quer dizer que ele não foi iniciado corretamente.

Para iniciar, você pode executar sudo service ssh start. Então faz o teste com o ss -lntp novamente.

O resultado foi esse gigante.

State                Recv-Q               Send-Q                               Local Address:Port                                Peer Address:Port               Process               
LISTEN               0                    32                                   192.168.122.1:53                                       0.0.0.0:*                                        
LISTEN               0                    4096                                 127.0.0.53%lo:53                                       0.0.0.0:*                                        
LISTEN               0                    128                                        0.0.0.0:22                                       0.0.0.0:*                                        
LISTEN               0                    5                                        127.0.0.1:631                                      0.0.0.0:*                                        
LISTEN               0                    64                                         0.0.0.0:45695                                    0.0.0.0:*                                        
LISTEN               0                    4096                                       0.0.0.0:49727                                    0.0.0.0:*                                        
LISTEN               0                    64                                         0.0.0.0:2049                                     0.0.0.0:*                                        
LISTEN               0                    4096                                       0.0.0.0:40933                                    0.0.0.0:*                                        
LISTEN               0                    10                                       127.0.0.1:2222                                     0.0.0.0:*                                        
LISTEN               0                    4096                                       0.0.0.0:111                                      0.0.0.0:*                                        
LISTEN               0                    4096                                       0.0.0.0:35249                                    0.0.0.0:*                                        
LISTEN               0                    128                                           [::]:22                                          [::]:*                                        
LISTEN               0                    5                                            [::1]:631                                         [::]:*                                        
LISTEN               0                    4096                                          [::]:34207                                       [::]:*                                        
LISTEN               0                    64                                            [::]:40449                                       [::]:*                                        
LISTEN               0                    64                                            [::]:2049                                        [::]:*                                        
LISTEN               0                    4096                                          [::]:43297                                       [::]:*                                        
LISTEN               0                    4096                                          [::]:58735                                       [::]:*                                        
LISTEN               0                    4096                                          [::]:111                                         [::]:* 

Antes de rodar a sua sugestão tentei o install novamente e apareceu que já tinha instalada a última versão. Acredito que resolveu após aquela questão do UEFI e Secure Boot em que me auxiliou no curso de Ansible (https://cursos.alura.com.br/forum/topico-vagrant-up-nao-sobe-a-maquina-virtual-141333#909955).

Aguardarei antes de marcar como solucionado, para saber se é normal tantas entradas aparecerem.

Obrigado.

solução!

André, cada serviço tem uma porta. O SSH usa a 22 que está na sua listagem, por exemplo. Como você está estudando, deve ter instalado alguns programas e eles ficam ativos por padrão quando instalados, então não é anormal que a saída tenha sido grande.

Você pode verificar quais serviços usam quais portas por padrão no arquivo /etc/services .

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software