ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机
生活随笔
收集整理的這篇文章主要介紹了
ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用下例中ssky-keygen和ssh-copy-id,僅需通過3個步驟的簡單設置而無需輸入密碼就能登錄遠程Linux主機。?
ssh-keygen 創建公鑰和密鑰。?
ssh-copy-id 把本地主機的公鑰復制到遠程主機的authorized_keys文件上。
ssh-copy-id 也會給遠程主機的用戶主目錄(home)和~/.ssh, 和~/.ssh/authorized_keys設置合適的權限 。
步驟1: 用 ssh-key-gen 在本地主機上創建公鑰和密鑰
root@zc-Lenovo-B450:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/zc/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/zc/.ssh/id_rsa. Your public key has been saved in /home/zc/.ssh/id_rsa.pub. The key fingerprint is: db:fd:13:dc:f5:99:4b:0a:c1:53:bf:f3:5f:c3:5c:2e zc@zc-Lenovo-B450 The key's randomart image is: +--[ RSA 2048]----+ | | | . | | . . . | | + ..| | S o. .B| | o o =B+| | . . o E=*| | o.o+| | ..o| +-----------------+步驟2: 用 ssh-copy-id 把公鑰復制到遠程主機上
root@zc-Lenovo-B450:~$ ssh-copy-id 192.168.0.191 root@192.168.0.191's password: Now try logging into the machine, with "ssh '192.168.0.191'", and check in:~/.ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.步驟3: 直接登錄遠程主機
root@zc-Lenovo-B450:/home/zc# ssh 192.168.0.191 Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-17-generic-pae i686)* Documentation: https://help.ubuntu.com/364 packages can be updated. 299 updates are security updates.New release '12.04 LTS' available. Run 'do-release-upgrade' to upgrade to it.You have new mail. Last login: Mon Feb 4 15:02:51 2013 from zc-lenovo-b450.local?
轉載于:https://www.cnblogs.com/firesnow/archive/2013/02/04/2891825.html
總結
以上是生活随笔為你收集整理的ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 24小时改变你的人生【转】
- 下一篇: uva10891Game of sum