[other] localhost和127.0.0.1都显示已拒绝连接
Tofloor
poster avatar
Meggie
deepin
2024-01-06 18:35
Author

localhost和127.0.0.1都显示已拒绝连接

host文件、host.allow文件、hosts.allow文件都添加了映射,防火墙也都关闭了,可还是连不上,谁能帮我解决下

Reply Favorite View the author
All Replies
liwl
deepin
2024-01-06 18:39
#1

sudo apt install openssh-server

Reply View the author
waittingsummer
deepin
2024-01-06 18:56
#2

deepin默认没装ssh服务

Reply View the author
Meggie
deepin
2024-01-06 22:11
#3

安装ssh服务后也是连接失败

Reply View the author
neko
deepin
Ecological co-builder
2024-01-06 22:56
#4
Meggie

安装ssh服务后也是连接失败

sudo systemctl enable ssh #开机自启

sudo systemctl start ssh #立即启动ssh服务

Reply View the author
Meggie
deepin
2024-01-07 10:20
#5
neko

sudo systemctl enable ssh #开机自启

sudo systemctl start ssh #立即启动ssh服务

都试过了还是不行,好像是ipv6和ipv4优先级的事,在一个帖子看过但是是windows的,linux的没找到啊😥

Reply View the author
Meggie
deepin
2024-01-07 10:41
#6

ipv4优先级设置完了,ping都没问题,但还是显示“127.0.0.1 已拒绝连接”,😭

Reply View the author
neko
deepin
Ecological co-builder
2024-01-07 16:47
#7
Meggie

ipv4优先级设置完了,ping都没问题,但还是显示“127.0.0.1 已拒绝连接”,😭

sudo netstat -tlpn看看

Reply View the author
waittingsummer
deepin
2024-01-08 09:12
#8

image.png

vim /etc/ssh/sshd_config

1.把 StrictModesyes改为 no

2.在AllowUsers后面加上你的用户名,多个用户名之间空格隔开,最前面的deepin不用管

image.png

然后 sudo systemctl restart sshd看看

Reply View the author
Meggie
deepin
2024-01-12 22:06
#9
neko

sudo netstat -tlpn看看

显示下面的信息

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:6060 0.0.0.0:* LISTEN 1937/cpolar: master
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1676/cupsd
tcp 0 0 10.0.3.1:53 0.0.0.0:* LISTEN 1999/dnsmasq
tcp 0 0 127.0.0.1:4040 0.0.0.0:* LISTEN 2086/cpolar: worker
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1708/sshd: /usr/sbi
tcp 0 0 127.0.0.1:35600 0.0.0.0:* LISTEN 1935/ToDesk_Service
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 2127/smbd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 2127/smbd
tcp6 0 0 ::1:631 :::* LISTEN 1676/cupsd
tcp6 0 0 :::2017 :::* LISTEN 1939/v2raya
tcp6 0 0 :::46249 :::* LISTEN 3247/dde-cooperatio
tcp6 0 0 :::9200 :::* LISTEN 2086/cpolar: worker
tcp6 0 0 :::22 :::* LISTEN 1708/sshd: /usr/sbi
tcp6 0 0 :::139 :::* LISTEN 2127/smbd
tcp6 0 0 :::445 :::* LISTEN 2127/smbd

Reply View the author
neko
deepin
Ecological co-builder
2024-01-12 22:09
#10
Meggie

显示下面的信息

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:6060 0.0.0.0:* LISTEN 1937/cpolar: master
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1676/cupsd
tcp 0 0 10.0.3.1:53 0.0.0.0:* LISTEN 1999/dnsmasq
tcp 0 0 127.0.0.1:4040 0.0.0.0:* LISTEN 2086/cpolar: worker
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1708/sshd: /usr/sbi
tcp 0 0 127.0.0.1:35600 0.0.0.0:* LISTEN 1935/ToDesk_Service
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 2127/smbd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 2127/smbd
tcp6 0 0 ::1:631 :::* LISTEN 1676/cupsd
tcp6 0 0 :::2017 :::* LISTEN 1939/v2raya
tcp6 0 0 :::46249 :::* LISTEN 3247/dde-cooperatio
tcp6 0 0 :::9200 :::* LISTEN 2086/cpolar: worker
tcp6 0 0 :::22 :::* LISTEN 1708/sshd: /usr/sbi
tcp6 0 0 :::139 :::* LISTEN 2127/smbd
tcp6 0 0 :::445 :::* LISTEN 2127/smbd

sshd看上去正常启动了,ssh $USER@0 试试可以连接吗

Reply View the author
Meggie
deepin
2024-01-12 22:22
#11
waittingsummer

image.png

vim /etc/ssh/sshd_config

1.把 StrictModesyes改为 no

2.在AllowUsers后面加上你的用户名,多个用户名之间空格隔开,最前面的deepin不用管

image.png

然后 sudo systemctl restart sshd看看

你好,按照你的方法试了下,还是访问不了啊😭

Reply View the author
Meggie
deepin
2024-01-12 22:26
#12
neko

sshd看上去正常启动了,ssh $USER@0 试试可以连接吗

可以连接

admin@admin-PC:~$$USER@0

The authenticity of host '0.0.0.0 (0.0.0.0)' can't be established.
ED25519 key fingerprint is SHA256:0vxXhAPbGZHo5drVipyEsD0woliv4T/imW7THtlmc.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '0.0.0.0' (ED25519) to the list of known hosts.
[email protected]'s password:
验证成功
验证成功
Linux admin-PC 6.1.32-amd64-desktop-hwe #23.01.00.20 SMP PREEMPT_DYNAMIC Mon Sep 11 14:16:03 CST 2023 x86_64
Welcome to Deepin 23 GNU/Linux

* Homepage:https://www.deepin.org/

* Bugreport:https://bbs.deepin.org/
Reply View the author