建立不用ssh密碼登陸的docker鏡像

來源:互聯網
上載者:User

標籤:docker ssh

作業系統:vm centos6.5 

容器:docker 

前提:可以ssh的docker鏡像已經建立


第一種方法,手動建立


1.在宿主機上產生新的密鑰和公開金鑰

###ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment] [-foutput_keyfile]#ssh-keygen的具體用法參考官方文檔ssh-keygen -q -N "" -t dsa -f /root/.ssh/id_dsa


2.然後把公開金鑰放在建立好的docker容器中去

ssh -o StrictHostKeyChecking=no [email protected]mkdir -p /root/.sshecho "..." >> /root/.ssh/authorized_keys


3.在宿主機上測試ssh串連

[[email protected]_admin_192.168.240.148_61618_A ~]$ ssh 172.17.0.2 Last login: Sat Aug 2 11:16:10 2014 from 172.17.42.1 [[email protected]_admin_172.17.0.2_22_A ~]$


第二種方法,指令碼建立

原理是一樣的,都是產生密鑰和公開金鑰,然後匯入密鑰


本文出自 “營運小卒” 部落格,謝絕轉載!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.