一、
在 Client 端建立 Public 與 Private Key
$ ssh-keygen -t dsa (這個步驟產生Keys)
Generating public/private dsa key pair.
Enter file in which to save the key (/home/root/.ssh/id_dsa):按下 Enter
Enter passphrase (empty for no passphrase):按下 Enter
Enter same passphrase again:按下 Enter
Your identification has been saved in /home/root/.ssh/id_dsa. (私鑰)
Your public key has been saved in /home/root/.ssh/id_dsa.pub. (公鑰)
The key fingerprint is:
7f:22:6b:ba:2d:35:46:ac:2b:18:e7:91:27:e9:bc:19 root@free.com.tw
The key's randomart image is:
+--[ DSA 1024]----+
| |
| |
| . |
| o |
| o oS |
| . * o +. |
| BE+ +..o . |
| . =oo..o o |
| ooo=o |
+-----------------+
二、
在 Server 端放置 Client 可以登入的公鑰 (假設Server主機IP為192.168.10.10)
$cd ~/.ssh (先回到家目錄中下的.ssh資料夾中)
$scp id_dsa.pub root@192.168.10.10:~/ (使用scp複製client端的公鑰到server端主機的目錄下)
若server端的ssh port有更改為其它port的話,可再加入 -P參數如下
$scp -P 8080 id_dsa.pub root@192.168.10.10:~/
三、
登入到 Server 端,將公鑰轉存到 authorized_keys 檔案中
$ssh 192.168.10.10
$cat id_dsa.pub >> .ssh/authorized_keys
建立完成之後,client端即可不用免密碼登入ssh server主機
Copyright © 2009 New Life in Taipei All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.
0 回應:
張貼留言