個人心情和 Linux / FreeBSD 等技術

2009/08/27

ssh-keygen

這已經在公司用了好久了,不是什麼了不起的應用

來這裡筆記一下吧

詳細的使用看 manpage 第一段就明確的告訴你

ssh-keygen generates, manages and converts authentication keys
for ssh(1). ssh-keygen can create
RSA keys for use by
SSH protocol version 1 and RSA or DSA keys for use by SSH
protocol version 2. The type of key to be generated is specified
with the -t option. If invoked without any arguments, ssh-keygen
will generate an RSA key for use in SSH protocol 2 connections.

預設不自作聰明的帶參數的話會是 SSH protocol 2 可使用的 RSA key。

但是 RSA非對稱式加密 有些歷史因素,個人認為在 1024 bits 以下都很危險..


所以個人還是偏好使用 DSA演算法

廢話不多說來產生 key

rellik@desktop(01:05:08)[~]$
ssh-keygen -t dsa

Generating public/private dsa key pair.
Enter file in which to save the key (/home/rellik/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/rellik/.ssh/id_dsa.
Your public key has been saved in /home/rellik/.ssh/id_dsa.pub.

大概按兩三次 Enter 鍵就結束了

而在工作環境下我的 HOME 目錄又是使用 NFS 掛載到每一台機器上的

這有個好處可以讓我快速的游移在多台機器中不需要打帳號密碼節省了

很多敲鍵盤的時間。

作法是在 $HOME/.ssh 目錄底下建立一個 authorized_keys

然後把 $HOME/.ssh/id_dsa.pub (記得是 public key 呀)貼到

authorized_keys 裡,權限 600 ,這樣就可以利用 nfs 快速的在

機器間遊走了 。

最後忘了說,Debian liked 的系統強烈建議安裝 openssh-blacklist

這個套件 ......, 不清楚的人可參考之前的文章 Debian的openssl漏洞