linux scp传输文件权限被拒绝,Linux的远程传输文件scp及出现Permission denied (publickey).lost connection问题解决方法...
一、Linux的遠程傳輸文件scp使用方法
1.當(dāng)前Linux系統(tǒng) --> 遠程Linux系統(tǒng)
scp 當(dāng)前Linux系統(tǒng)文件路徑/文件名 遠程Linux用戶名@IP地址:遠程Linux系統(tǒng)文件路徑
2.遠程Linux系統(tǒng) -->當(dāng)前Linux系統(tǒng)
scp 遠程Linux用戶名@IP地址:遠程Linux系統(tǒng)文件路徑/文件名 當(dāng)前Linux系統(tǒng)文件路徑
例如傳輸文件:
scp /home//windscribe-cli_1.3-19_amd64.deb root@172.28.128.4:/home/
二、遠程傳輸時權(quán)限被拒絕的解決方法
傳輸時出現(xiàn)錯誤:
Permission denied (publickey).
lost connection
權(quán)限被拒絕(publickey)
失去了連接
方法1:
1.登錄遠程主機,將/etc/ssh/sshd_config文件中的PasswordAuthentication no改為PasswordAuthentication yes
2.重啟sshd服務(wù):
systemctl restart ssh.service
然而我使用這種方法還是沒有解決問題..
方法2:
1.在當(dāng)前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.
執(zhí)行完畢后會在用戶目錄~/.ssh/產(chǎn)生兩個文件,id_rsa,id_rsa.pub
2.將當(dāng)前Linux主機上的id_rsa.pub文件拷貝到遠程Linux主機的root用戶目錄下的.ssh目錄下,并且改名為authorized_keys?。若已經(jīng)有該文件覆蓋掉內(nèi)容即可。
這樣在當(dāng)前Linux主機上使用scp命令傳輸文件到遠程Linux上將不提示輸入密碼了,直接傳輸了。也可在當(dāng)前Linux主機上使用scp命令將遠程Linux上文件傳輸?shù)奖緳C;總之不需要驗證,就可以在當(dāng)前Linux系統(tǒng)訪問遠程Linux系統(tǒng)
注:如果有多臺計算機需要與遠程Linux系統(tǒng)進行傳輸,則只需將id_rsa.pub中的內(nèi)容復(fù)制到authorized_keys文件中即可。
3.再次執(zhí)行傳輸命令:
scp /home//windscribe-cli_1.3-19_amd64.deb root@172.28.128.4:/home/
已經(jīng)可以使用。
總結(jié)
以上是生活随笔為你收集整理的linux scp传输文件权限被拒绝,Linux的远程传输文件scp及出现Permission denied (publickey).lost connection问题解决方法...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: EMC封装成形常见缺陷
- 下一篇: 小型仓库管理系统MySQL