[email protected] .ssh $ ssh copy id [email protected] /bin/ssh copy id: INFO: attempting to ...">

当前位置:网站首页>port 22: Connection refused

port 22: Connection refused

2022-06-24 09:49:00 yitahutu79

Prompt connection failure when setting password free login

[[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

see 22 Is port number on ss -lnt , The result is not turned on

[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]

Aware that it may be SSH The service is not installed so download and install sudo apt-get install openssh-server openssh-client

[email protected] .ssh % sudo apt-get install openssh-server openssh-client   
[sudo] lj  Password : 
 Reading package list ...  complete 
 Analyzing package dependency tree        
 Reading status information ...  complete        
openssh-client  It's the latest edition  (1:8.2p1-4ubuntu0.5).
openssh-client  Set to manual installation .
 The following packages are installed automatically and are no longer needed :
  libfprint-2-tod1 libfwupdplugin1 libllvm10
 Use 'sudo apt autoremove' To uninstall it ( they ).
 The following software will be installed at the same time :
  ncurses-term openssh-sftp-server ssh-import-id
 Proposed installation :
  molly-guard monkeysphere ssh-askpass
 The following 【 new 】 The package will be installed :
  ncurses-term openssh-server openssh-sftp-server ssh-import-id
 The upgrade  0  Software package , New installation  4  Software package , To uninstall  0  Software package , Yes  9  Packages not upgraded .
 Need to download  688 kB  The filing of .
 After decompression, it will consume  6,010 kB  Extra space .
 Would you like to continue ? [Y/n] y
 obtain :1 http://ftp.sjtu.edu.cn/ubuntu focal/main amd64 ncurses-term all 6.2-0ubuntu2 [249 kB]
 obtain :2 http://ftp.sjtu.edu.cn/ubuntu focal-updates/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.5 [51.5 kB]
 obtain :3 http://ftp.sjtu.edu.cn/ubuntu focal-updates/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.5 [377 kB]
 obtain :4 http://ftp.sjtu.edu.cn/ubuntu focal/main amd64 ssh-import-id all 5.10-0ubuntu1 [10.0 kB]
 Downloaded  688 kB, Time consuming  10 second  (65.5 kB/s)
 Presetting package  ...
 Selecting unselected packages  ncurses-term.
( Reading database  ...  The system currently has  170245  Two files and directories .)
 Ready to unzip  .../ncurses-term_6.2-0ubuntu2_all.deb  ...
 Decompressing  ncurses-term (6.2-0ubuntu2) ...
 Selecting unselected packages  openssh-sftp-server.
 Ready to unzip  .../openssh-sftp-server_1%3a8.2p1-4ubuntu0.5_amd64.deb  ...
 Decompressing  openssh-sftp-server (1:8.2p1-4ubuntu0.5) ...
 Selecting unselected packages  openssh-server.
 Ready to unzip  .../openssh-server_1%3a8.2p1-4ubuntu0.5_amd64.deb  ...
 Decompressing  openssh-server (1:8.2p1-4ubuntu0.5) ...
 Selecting unselected packages  ssh-import-id.
 Ready to unzip  .../ssh-import-id_5.10-0ubuntu1_all.deb  ...
 Decompressing  ssh-import-id (5.10-0ubuntu1) ...
 Setting up  openssh-sftp-server (1:8.2p1-4ubuntu0.5) ...
 Setting up  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.
 Setting up  ssh-import-id (5.10-0ubuntu1) ...
Attempting to convert /etc/ssh/ssh_import_id
 Setting up  ncurses-term (6.2-0ubuntu2) ...
 Processing for  systemd (245.4-4ubuntu3.17)  The trigger of  ...
 Processing for  man-db (2.9.1-1)  The trigger of  ...
 Processing for  ufw (0.36-6ubuntu1)  The trigger of  ...

Check again , After installation 22 The port has been opened

[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            [::]:*

Run again , success

[[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)


原网站

版权声明
本文为[yitahutu79]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240837584939.html