当前位置:网站首页>port 22: Connection refused
port 22: Connection refused
2022-06-24 08:38:00 【yitahutu79】
设置免密登录时提示连接失败
[[email protected] .ssh]$ ssh-copy-id [email protected]
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: ERROR: ssh: connect to host 192.168.145.129 port 22: Connection refused
查看22号端口是否开启ss -lnt ,结果是未开启
[email protected] .ssh % ss -lnt [0]
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 5 [::1]:631 [::]:*
[email protected] .ssh % lsof -i:22 [0]
察觉到可能是SSH服务未安装因此进行下载安装sudo apt-get install openssh-server openssh-client
[email protected] .ssh % sudo apt-get install openssh-server openssh-client
[sudo] lj 的密码:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
openssh-client 已经是最新版 (1:8.2p1-4ubuntu0.5)。
openssh-client 已设置为手动安装。
下列软件包是自动安装的并且现在不需要了:
libfprint-2-tod1 libfwupdplugin1 libllvm10
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
ncurses-term openssh-sftp-server ssh-import-id
建议安装:
molly-guard monkeysphere ssh-askpass
下列【新】软件包将被安装:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
升级了 0 个软件包,新安装了 4 个软件包,要卸载 0 个软件包,有 9 个软件包未被升级。
需要下载 688 kB 的归档。
解压缩后会消耗 6,010 kB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://ftp.sjtu.edu.cn/ubuntu focal/main amd64 ncurses-term all 6.2-0ubuntu2 [249 kB]
获取:2 http://ftp.sjtu.edu.cn/ubuntu focal-updates/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.5 [51.5 kB]
获取:3 http://ftp.sjtu.edu.cn/ubuntu focal-updates/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.5 [377 kB]
获取:4 http://ftp.sjtu.edu.cn/ubuntu focal/main amd64 ssh-import-id all 5.10-0ubuntu1 [10.0 kB]
已下载 688 kB,耗时 10秒 (65.5 kB/s)
正在预设定软件包 ...
正在选中未选择的软件包 ncurses-term。
(正在读取数据库 ... 系统当前共安装有 170245 个文件和目录。)
准备解压 .../ncurses-term_6.2-0ubuntu2_all.deb ...
正在解压 ncurses-term (6.2-0ubuntu2) ...
正在选中未选择的软件包 openssh-sftp-server。
准备解压 .../openssh-sftp-server_1%3a8.2p1-4ubuntu0.5_amd64.deb ...
正在解压 openssh-sftp-server (1:8.2p1-4ubuntu0.5) ...
正在选中未选择的软件包 openssh-server。
准备解压 .../openssh-server_1%3a8.2p1-4ubuntu0.5_amd64.deb ...
正在解压 openssh-server (1:8.2p1-4ubuntu0.5) ...
正在选中未选择的软件包 ssh-import-id。
准备解压 .../ssh-import-id_5.10-0ubuntu1_all.deb ...
正在解压 ssh-import-id (5.10-0ubuntu1) ...
正在设置 openssh-sftp-server (1:8.2p1-4ubuntu0.5) ...
正在设置 openssh-server (1:8.2p1-4ubuntu0.5) ...
Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...
3072 SHA256:1j46TJASEI//oOKLmgAcI8vQnJWxZHemllI/kqPXkEc [email protected] (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:l6Stjl1ZVKPuTmvFA6uLMEeaaUHjR9Dx4xPDLWFqzVQ [email protected] (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:7h0kKmUYhxTP65ZEIdrAWGCxZb7x5tWXPdFR4tWJ6/w [email protected] (ED25519)
Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.
Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service.
rescue-ssh.target is a disabled or a static unit, not starting it.
正在设置 ssh-import-id (5.10-0ubuntu1) ...
Attempting to convert /etc/ssh/ssh_import_id
正在设置 ncurses-term (6.2-0ubuntu2) ...
正在处理用于 systemd (245.4-4ubuntu3.17) 的触发器 ...
正在处理用于 man-db (2.9.1-1) 的触发器 ...
正在处理用于 ufw (0.36-6ubuntu1) 的触发器 ...
再次进行查询,安装之后22端口已经打开
[email protected] .ssh % lsof -i:22 [0]
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ssh 11870 lj 3u IPv4 137835 0t0 TCP ubuntu:50830->ubuntu:ssh (ESTABLISHED)
[email protected] .ssh % ss -lnt [0]
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
再次运行,成功
[[email protected] ~]$ ssh-copy-id [email protected]
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/lj/.ssh/id_rsa.pub"
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
(if you think this is a mistake, you may want to use -f option)
边栏推荐
- Oracle数据库EXPDP只导出表的方法
- Cdga | how can we do well in data governance?
- Oracle database expdp only exports tables
- Niuke network decimal integer to hexadecimal string
- Recommendation - Secret of curiosity: how many dancing angels can stand on the tip of a needle?
- LeetCode: 137. 只出现一次的数字 II
- When should gridfs be used?
- 医学图像开源数据集汇总(二)
- 带文字的seekbar : 自定义progressDrawable/thumb :解决显示不全
- 百度AI模板 获取知识理解
猜你喜欢
随机推荐
算法--找到和最大的长度为 K 的子序列(Kotlin)
e的lnx为什么等于x
深入解析 Apache BookKeeper 系列:第三篇——读取原理
Time series data augmentation for deep learning: paper reading of a survey
【Eureka注册中心】
R ellipse random point generation and drawing
Thinkphp5清除runtime下的cache缓存,temp缓存,log缓存
Oracle的tnsnames.ora文件配置
谈谈数字化转型晓知识
最新Windows下Go语言开发环境搭建+GoLand配置
软件系统依赖关系分析
转:三星电子CEO:一切决策都要从认清自己开始
How to make social media the driving force of cross-border e-commerce? This independent station tool cannot be missed!
Oracle database expdp only exports tables
Longest public prefix of leetcode
Threejs point light + ambient light
Zero foundation self-study SQL course | having clause
每周推荐短视频:谈论“元宇宙”要有严肃认真的态度
Conseils étonnants pour promouvoir les ventes d'entreprise avec le chat en direct
Easyexcel single sheet and multi sheet writing








