Linux傳輸文件權限被拒絕:Access denied for user 'fuguang_user'@'localhost' (using password: YES)


一、Linux的遠程傳輸文件scp使用方法

1.當前Linux系統 --> 遠程Linux系統

scp 當前Linux系統文件路徑/文件名 遠程Linux用戶名@IP地址:遠程Linux系統文件路徑

2.遠程Linux系統 -->當前Linux系統

scp 遠程Linux用戶名@IP地址:遠程Linux系統文件路徑/文件名 當前Linux系統文件路徑

例如傳輸文件:

scp /home//windscribe-cli_1.3-19_amd64.deb root@172.28.128.4:/home/

二、遠程傳輸時權限被拒絕的解決方法

傳輸時出現錯誤:

Permission denied (publickey).

lost connection

權限被拒絕(publickey)

失去了連接

方法1:

1.登錄遠程主機,將 /etc/ssh/sshd_config 文件中的 PasswordAuthentication no 改為 PasswordAuthentication yes

2.重啟sshd服務:

systemctl restart ssh.service

然而我使用這種方法還是沒有解決問題..

方法2:

1.在當前Linux主機中運行以下命令

ssh-keygen -t rsa

運行過程的操作如下:

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/ssh/id_rsa):#回車
Enter passphrase (empty for no passphrase):#回車
Enter same passphrase again:#回車
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.

執行完畢后會在用戶目錄 ~/.ssh/ 產生兩個文件, id_rsaid_rsa.pub

2.將當前Linux主機上的id_rsa.pub文件拷貝到遠程Linux主機的root用戶目錄下的 .ssh 目錄下,並且改名為 authorized_keys 。若已經有該文件覆蓋掉內容即可。

這樣在當前Linux主機上使用 scp 命令傳輸文件到遠程Linux上將不提示輸入密碼了,直接傳輸了。也可在當前Linux主機上使用 scp 命令將遠程Linux上文件傳輸到本機;總之不需要驗證,就可以在當前Linux系統訪問遠程Linux系統

注:如果有多台計算機需要與遠程Linux系統進行傳輸,則只需將 id_rsa.pub 中的內容復制到 authorized_keys 文件中即可。

3.再次執行傳輸命令:

scp /home//windscribe-cli_1.3-19_amd64.deb root@172.28.128.4:/home/

已經可以使用。

轉載於:https://blog.csdn.net/weixin_42333009/article/details/116731707


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM