SOLUÇÃO: remover e purgar tudo!¶
Problemas:¶
Problema encontrado:¶
# ssh ameixa@150.162.53.251
ssh: connect to host 150.162.53.251 port 22: Connection refused
Verificamos se a porta 22 estava aberta:
# nmap -v 150.162.53.251 -p 22
resposta:
Starting Nmap 7.40 ( https://nmap.org ) at 2017-09-13 10:08 -03
Initiating ARP Ping Scan at 10:08
Scanning 150.162.53.251 [1 port]
Completed ARP Ping Scan at 10:08, 0.22s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 10:08
Completed Parallel DNS resolution of 1 host. at 10:08, 0.00s elapsed
Initiating SYN Stealth Scan at 10:08
Scanning 150.162.53.251 [1 port]
Completed SYN Stealth Scan at 10:08, 0.22s elapsed (1 total ports)
Nmap scan report for 150.162.53.251
Host is up (0.0056s latency).
PORT STATE SERVICE
22/tcp closed ssh
MAC Address: FC:99:47:42:FC:C0 (Cisco Systems)
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.65 seconds
Raw packets sent: 3 (116B) | Rcvd: 3 (108B)
Obviamente, conectando no localhost a conexão acontece.
# ssh localhost
# ssh ameixa@150.162.53.251
# ssh ameixa@ameixa-mesh
Problema ainda não investigado:¶
# service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2017-09-13 10:30:37 -03; 4min 38s ago
Process: 817 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 648 (sshd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/ssh.service
└─648 /usr/sbin/sshd -D
set 13 10:30:40 ameixa-mesh systemd[1]: Reloaded OpenBSD Secure Shell server.
set 13 10:30:40 ameixa-mesh sshd[648]: Could not load host key: /etc/ssh/ssh_host_rsa_key
set 13 10:30:40 ameixa-mesh sshd[648]: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
set 13 10:30:40 ameixa-mesh sshd[648]: Could not load host key: /etc/ssh/ssh_host_ed25519_key
set 13 10:30:40 ameixa-mesh sshd[648]: Server listening on 0.0.0.0 port 223.
set 13 10:30:40 ameixa-mesh sshd[648]: Server listening on :: port 223.
set 13 10:30:40 ameixa-mesh sshd[648]: Server listening on 0.0.0.0 port 135.
set 13 10:30:40 ameixa-mesh sshd[648]: Server listening on :: port 135.
set 13 10:30:40 ameixa-mesh sshd[648]: Server listening on 0.0.0.0 port 22.
set 13 10:30:40 ameixa-mesh sshd[648]: Server listening on :: port 22.
Could not load host key
Tentativas: (nada funcionou)¶
Verificar a configuração do sshd¶
# gedit /etc/ssh/sshd_config
A porta 22 estava comentada. Descomentamos. Nada mudou.
Mexer na instalação do sshsever¶
reinstalar:# apt-get remove sshserver
# apt-get install sshserver
reconfigurar:
# dpkg-reconfigure openssh-server
Acrescentar a porta 22 na IPTABLES¶
# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Recriar as chaves SSH¶
# ssh-keygen -A
Instalar o inetd!¶
ou o xinetd??
Instalar e configurar o UFW¶
UFW – uncomplicated firewall
liberar serviço ssh
# ufw allow ssh
adicionar um IP específico para uma porta específica:
# ufw allow from 192.168.1.10 to any port 22
referência:
www.cyberciti.biz/faq/how-to-open-firewall-port-on-ubuntu-linux-12-04-14-04-lts
firewalld¶
$ service firewalld status
resposta:
Unit firewalld.service could not be found.
Outras Infos:¶
como o nmap interpreta as portas (closed, filtered):
askubuntu.com/questions/408506/how-to-open-a-port
Status atual do SSHD ameixa-mesh:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-10-30 11:33:58 -02; 1min 19s ago
Process: 30427 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 3052 (sshd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/ssh.service
└─3052 /usr/sbin/sshd -D
out 30 11:33:58 ameixa-mesh systemd[1]: Stopped OpenBSD Secure Shell server.
out 30 11:33:58 ameixa-mesh systemd[1]: Starting OpenBSD Secure Shell server...
out 30 11:33:58 ameixa-mesh sshd[3052]: Server listening on 0.0.0.0 port 64666.
out 30 11:33:58 ameixa-mesh sshd[3052]: Server listening on :: port 64666.
out 30 11:33:58 ameixa-mesh systemd[1]: Started OpenBSD Secure Shell server.
out 30 11:33:58 ameixa-mesh sshd[3052]: Server listening on 0.0.0.0 port 8080.
out 30 11:33:58 ameixa-mesh sshd[3052]: Server listening on :: port 8080.
out 30 11:33:58 ameixa-mesh sshd[3052]: Server listening on 0.0.0.0 port 22.
out 30 11:33:58 ameixa-mesh sshd[3052]: Server listening on :: port 22.