Ali cloud configuration universal service pit ssh: connect to host 47.103.101.102 port 22: Connection refused

1、~ wjw$ ssh [email protected]

ssh: Connect to Host 47.103.101.102 Port 22: Connection refused The
ssh service is not open: according to Solutions online:
1, restart the ssh service
$ sudo service ssh restart or $ / etc / init.d / ssh restart
check the service status:
$ ps -ef | grep ssh
result is empty.
Possible reasons, ssh client and server does not match
2, reinstall:
first remove
$ sudo apt-get move openssl- server openssl-client
before installing
sudo apt-get install openssl-server openssl-client
update
sudo apt-get update
open ssh service
$ sudo service ssh start or /etc/init.d/ssh start
prompt
page telnet:
$ systemctl Status firewalld
prompted
ssh start / running
but
$ ps -ef | grep ssh
result was empty.

3, suspected ssh configuration problem?
$ vi / etc / ssh / ssh_config
open
Ptorocol 2
Prot 2
save and exit and restart the service, is not valid. . . It estimated that many people regard this step to solve the problem

4, open cloud Ali, detect security group policy
22 default Ali cloud INPUT port is open to you.
View occupancy 22 ports
$ lsof -i: 22
No information

In this issue should not be

5, may be in the iptables firewall rules restart the instance when I last configured not take effect automatically
change the firewall configuration rules directly turn off the firewall
$ sudo ufw disable
see ssh state again, still unable to connect
editing iptables

$ We /etc/iptables.rules

*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:syn-flood - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT
-A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN
-A syn-flood -j REJECT --reject-with icmp-port-unreachable
COMMIT

Save and exit
execute the command:
$ iptables-Restore </etc/iptables.rules
the rule to take effect.

** add rules to save

iptables-save /etc/iptables.roles

Edit / etc / network / interfaces file

vim /etc/network/interfaces

Add a line at the end of

pre-up iptables-restore < /etc/iptables.rules

Setup is complete

Add more content parameter Interpretation:

action before the card is enabled: pre-up
up: When enabled action
post-up: action after the opening
pre-down: action before closing
down: When the closing action of
post-down: shut down after action

2, the mismatch CI / usr / sshb / sshd of

In any case start, you can not start ssh service center had to reinstall openssl-server, of course openssl-client.
Is the cause of my problems, MAC end-use $ ssh root @ ip do when the remote connection is automatically dropped after a while, the Internet suggested that the number of automatic reconnection and reconnection configure ssh interval.
I guess it is an erroneous place, the last line of / usr / sbin / sshd has a ServerAliveInterval 60
online method is
$ cd / etc / SSH
$ vi ssh_config
last thing to add back
ServerAliveInterval 60
cause no matter $ / etc / init.d / ssh start or $ sudo service ssh start ssh service can not start, although already running ssh command prompt
using ps -ef | grep ssh when the list is always empty, see service.

root@Jarvis:~# /etc/init.d/ssh restart
ssh stop/waiting
ssh start/running
root@Jarvis:~# 

Guess you like

Origin www.cnblogs.com/wjw-blog/p/10966389.html