linux 下 scp 的用法

來源:互聯網
上載者:User
scp
使用 scp 在遠程機器上 copy 檔案
例如:
copy 本地的檔案到遠端機器上
scp /etc/lilo.conf k@net67.ee.oit.edu.tw:/home/k
會將本地的 /etc/lilo.conf 這個檔案 copy 到 net67.ee.oit.edu.tw,使用者 k 的家目錄下。
copy遠程機器上的檔案到本地來
scp k@net67.ee.oit.edu.tw:/etc/lilo.conf /etc
會將 net67.ee.oitdu.tw 中 /etc/lilo.conf 檔案 copy 到本地的 /etc 目錄下。
保持從來源 host 檔案的屬性
scp –p k@net67.ee.tw:/etc/lilo.conf /etc
在此必須注意使用者的許可權是否可讀取遠程上的檔案,若想知道更多關於 scp 的使用方法,可去看看 scp 的使用手冊。
ssh-keygen
產生公開鑰 (pulib key) 和私人鑰 (private key),以保障 ssh 聯機的安性, 當 ssh 連 shd 伺服器,會交換公開鑰上,系統會檢查 /etc/ssh_know_hosts 內儲存的 key,如果找到用戶端就用這個 key 產生一個隨機產生的session key 傳給伺服器,兩端都用這個 key 來繼續完成 ssh 剩下來的階段。

它會產生 identity.pub、identity 兩個檔案,私人鑰存放於identity,公開鑰 存放於 identity.pub 中,接下來使用 scp 將 identity.pub copy 到遠程機器的家目錄下.ssh下的authorized_keys。 .ssh/authorized_keys(這個 authorized_keys 檔案相當於協議的 rhosts 檔案), 之後使用者能夠不用密碼去登入。RSA的認證絕對是比 rhosts 認證更來的安全可靠。
執行:
scp identity.pub k@linux1.ee.oit.edu.tw:.ssh/authorized_keys

若在使用 ssh-keygen 產生鑰匙對時沒有輸入密碼,則如上所示不需輸入密碼即可從 net67.ee.oit.edu.tw 去登入 linux1.ee.oit.edu.tw。在此,這裡輸入的密碼可以跟帳號的密碼不同,也可以不輸入密碼。
抱歉,必需起用瀏覽器的 JavaScript 支援才能正常瀏覽。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.