如何开始监听 22 端口

如何开始监听 22 端口

我是 Linux 系统的新手。我在配置 ssh 时遇到了麻烦。

:~$ ssh localhost
ssh: connect to host localhost port 22: Connection refused

当我尝试调试它时,我得到了这个。

:~$ ssh -vvv localhost
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "localhost" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host localhost port 22: Connection refused

我运行了一些其他命令,但没有成功。

:~$ sudo iptables INPUT -p udp -dport 22
Bad argument `INPUT'.
Try 'iptables -h' or 'iptables --help' for more information.

我猜运行时没有输出sudo netstat -anp | grep sshd是因为机器没有列出端口 22。我不知道如何解决这个问题?

:~$ sudo ufw verbose
[sudo] password for hduser1: 
Status: inactive.

答案1

确保已经安装了 openssh-server

apt-get install openssh-server

并确保它正在运行

service ssh restart

查看openssh-server的状态:

systemctl status ssh

如果有任何错误,请尝试修复它们并重新启动 ssh 服务器。

相关内容