• 周六. 10 月 12th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Remote transmission file SCP of Linux and solutions to the problem of permission denied (public key)

King Wang

1 月 3, 2022

One 、Linux Remote transfer files for scp Usage method

1. At present Linux System –> long-range Linux System

scp At present Linux System file path / file name long-range Linux user name @IP Address : long-range Linux System file path 

2. long-range Linux System –> At present Linux System

scp long-range Linux user name @IP Address : long-range Linux System file path / file name At present Linux System file path 

For example, transfer files :

scp /home/vpn/windscribe-cli_1.3-19_amd64.deb [email protected]:/home/vpn

 

Two 、 The solution to permission denial in remote transmission

Error in transmission :

Permission denied (publickey).

lost connection

Permission denied (publickey)

Lost connection

 

Method 1:

1. Sign in Remote host , take /etc/ssh/sshd_config In the document PasswordAuthentication no  Change it to PasswordAuthentication yes

2. restart sshd service :

systemctl restart ssh.service

However, I still haven’t solved the problem with this method ..

 

Method 2:

1. At present Linux Run the following command from the host

ssh-keygen -t rsa

The operation of the running process is as follows :

Generating public/private rsa key pair. 
Enter file in which to save the key (/root/.ssh/ssh/id_rsa):  # enter  
Enter passphrase (empty for no passphrase):  # enter  
Enter same passphrase again:  # enter  

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

After execution It will be in the user directory ~/.ssh/ Generate two files ,id_rsa,id_rsa.pub

 

2. Will the current Linux Host computer id_rsa.pub File copy to remote Linux The host root User directory .ssh Under the table of contents , And renamed it authorized_keys . If there is already a file to cover the content can be .

In this way, at present Linux Use on main engine scp Command to transfer files to remote Linux The Admiral won’t prompt for a password , It’s transmitted directly . Or in the present Linux Use on main engine scp The command will be remote Linux Transfer files to this computer ; In short, there is no need to verify , You can do it right now Linux System access remote Linux System

notes : If there are multiple computers needed with remote Linux The system transmits , Then just put id_rsa.pub Copy the contents of to authorized_keys In the file .

 

3. Execute the transfer command again :

scp /home/vpn/windscribe-cli_1.3-19_amd64.deb [email protected]:/home/vpn

Already available .

 

 

 

发表回复