ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机
生活随笔
收集整理的這篇文章主要介紹了
ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
使用下例中ssky-keygen和ssh-copy-id,僅需通過(guò)3個(gè)步驟的簡(jiǎn)單設(shè)置而無(wú)需輸入密碼就能登錄遠(yuǎn)程Linux主機(jī)。?
ssh-keygen 創(chuàng)建公鑰和密鑰。?
ssh-copy-id 把本地主機(jī)的公鑰復(fù)制到遠(yuǎn)程主機(jī)的authorized_keys文件上。
ssh-copy-id 也會(huì)給遠(yuǎn)程主機(jī)的用戶主目錄(home)和~/.ssh, 和~/.ssh/authorized_keys設(shè)置合適的權(quán)限 。
步驟1: 用 ssh-key-gen 在本地主機(jī)上創(chuàng)建公鑰和密鑰
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 把公鑰復(fù)制到遠(yuǎn)程主機(jī)上
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: 直接登錄遠(yuǎn)程主機(jī)
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?
轉(zhuǎn)載于:https://www.cnblogs.com/firesnow/archive/2013/02/04/2891825.html
總結(jié)
以上是生活随笔為你收集整理的ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 24小时改变你的人生【转】
- 下一篇: 在 Linux 下使用 水星MW150c