自从上次重装阿里云搭建了Web服务器之后一直没有ssh连接过,今天再次连接时一直提示操作超时
ssh root@x.x.x.x
ssh: connect to host x.x.x.x port 22: Operation timed out
检查了机器的防火墙和阿里云的防火墙发现没有问题,然后修改了ssh端口连接依然不成功。
telnet可以连接成功说明不是防火墙问题
telnet x.x.x.x 10022
Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
于是添加-v参数查看连接时的debug信息
ssh -p 10022 root@x.x.x.x -v
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to x.x.x.x port 10022.
debug1: Connection established.
debug1: identity file /Users/jiangzhou/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiangzhou/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiangzhou/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiangzhou/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiangzhou/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiangzhou/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiangzhou/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiangzhou/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
ssh_exchange_identification: read: Operation timed out
百度之后发现了很多说法,最终尝试可行方案:
1、首先通过阿里云后台登录到ECS
2、执行
chmod 600 /etc/ssh/*
systemctl restart sshd
3、成功连接