TA的每日心情 | 开心 2016-5-12 14:23 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
SSH 密钥对可以让您方便的登录到 SSH 服务器,而无需输入密码。由于您无需发送您的密码到网络中,SSH 密钥对被认为是更加安全的方式。再加上使用密码短语 (passphrase) 的使用,安全性会更上一层楼。
. S% {8 z/ }: n
' ^0 v* M9 L0 R& K% m0 G0 U4 X同时,我们可以使用 SSH agent 来帮助我们记住密码短语,无需我们记住没一个密钥对的密码短语,减轻了我们的负担。 ! b% {: `* i8 o0 b: r2 K# L! _7 {, ?
0 U6 Y% i# Y0 E% ~
4 |4 p U. l; W$ a; j
我们可以使用 ssh-keygen 命令生成密钥对 ) x+ ]+ I: \4 _3 R
$ ssh-keygen -t ecdsa -b 521 -C "$(whoami)@$(hostname)-$(date -I)"* q( ]9 |) }: ^( @
$ V9 |, B6 D) o- Q3 P# D7 m5 M; e5 [
Generating public/private ecdsa key pair., Q- b9 B! Q9 s# G! a7 C8 W
Enter file in which to save the key (/home/username/.ssh/id_ecdsa):
. I3 ?; q7 e7 z4 y! R7 B- {" X9 hEnter passphrase (empty for no passphrase):
" n4 e- h$ Q7 wEnter same passphrase again:! A, @7 e& ~3 F( u, Y. o
Your identification has been saved in /home/username/.ssh/id_ecdsa.. i8 D& @- e! c, I K
Your public key has been saved in /home/username/.ssh/id_ecdsa.pub.3 A, g6 @% H9 o
The key fingerprint is:
1 v$ a7 G3 a3 U4 b( f$ T9 Pdd:15:ee:24:20:14:11:01:b8:72:a2:0f:99:4c:79:7f username@localhost-2011-12-22. b1 n$ j% V8 K) \
The key's randomart image is:
) C' \! n4 e$ p: B. |+--[ECDSA 521]---+. J6 O# Q3 ^; ~, x+ f8 n# r
| ..oB=. . |: G6 F1 H6 n/ g; ^
| . . . . . |
' Y! f+ h1 B# U5 e$ X6 D5 F# c| . . . + |
2 x" Q9 t% J. X' ?* Q; k# z% h# P| oo.o . . = |
" x4 G8 Y1 \. ^+ ~, L# E|o+.+. S . . . |
0 n$ J! B0 c: A' `( X6 i6 v* v|=. . E |
# I3 \9 |4 D$ T/ L1 @+ o| o . |% y. v, d1 V( [( {
| . |4 O* n) ^9 K- E' U
| |
; q5 K3 M8 P' u; Y8 L+-----------------+( k7 S) A: P+ C6 x7 }' r
9 q# B0 C9 I! n( A
在上面这个例子中,ssh-keygen 生成了一对长度为 512 bit (-b 512) 的 ECDSA (-t ecdsa) 加密的密钥对,comment 为 -C "$(whoami)@$(hostname)-$(date -I)"。而 randomart image 是 OpenSSH 5.1 引入的一种简单的识别指纹 (fingerprint) 的图像。
" o3 \" O! s. Y4 s' e( {& |4 n' }6 e* }5 U. n% c2 Z7 h
% b$ n& x7 D4 B+ e) Z7 q& A
...... please refer to the URL: https://wiki.archlinux.org/index.php/SSH_Keys_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87) |
|