質問編集履歴
2
一部修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -178,4 +178,4 @@
|
|
178
178
|
|
179
179
|
ssh-rsa AAAA*********・・・
|
180
180
|
|
181
|
-
```
|
181
|
+
```
|
1
ご質問頂いた情報を追記させて頂きました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,3 +33,149 @@
|
|
33
33
|
|
34
34
|
|
35
35
|
宜しくお願いします。
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
ーーー追記ーーーー
|
40
|
+
|
41
|
+
ldapのバージョン:2.4.40
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
◆SSH公開鍵の登録方法
|
46
|
+
|
47
|
+
※ldifファイルに記述
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
/etc/ldap/ldif/user.ldif
|
52
|
+
|
53
|
+
```lang-user.ldif
|
54
|
+
|
55
|
+
dn: uid=username,ou=User,dc=example,dc=co,dc=jp
|
56
|
+
|
57
|
+
objectClass: shadowAccount
|
58
|
+
|
59
|
+
objectClass: posixAccount
|
60
|
+
|
61
|
+
objectClass: account
|
62
|
+
|
63
|
+
objectClass: top
|
64
|
+
|
65
|
+
objectCkass: ldapPublicKey
|
66
|
+
|
67
|
+
cn: username
|
68
|
+
|
69
|
+
uid: username
|
70
|
+
|
71
|
+
uidNumber: 2001
|
72
|
+
|
73
|
+
gidNumber: 2000
|
74
|
+
|
75
|
+
homeDirectory: /home/username
|
76
|
+
|
77
|
+
loginShell: /bin/bash
|
78
|
+
|
79
|
+
shadowMin: 0
|
80
|
+
|
81
|
+
shadowMax: 99999
|
82
|
+
|
83
|
+
shadowWarning: 7
|
84
|
+
|
85
|
+
shadowLastChange: 16175
|
86
|
+
|
87
|
+
userPassword: {SSHA}*************************************
|
88
|
+
|
89
|
+
sshPublicKey: ssh-rsa AAAA**********************************
|
90
|
+
|
91
|
+
```
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
※openssh-lpkスキーマの追加
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
/etc/ldap/ldif/openssh-lpk.ldif
|
100
|
+
|
101
|
+
```lang
|
102
|
+
|
103
|
+
dn: cn=openssh-lpk,cn=schema,cn=config
|
104
|
+
|
105
|
+
objectClass: olcSchemaConfig
|
106
|
+
|
107
|
+
cn: openssh-lpk
|
108
|
+
|
109
|
+
olcAttributeTypes: ( 1.3.6.1.4.1.24552.500.1.1.1.13 NAME 'sshPublicKey'
|
110
|
+
|
111
|
+
DESC 'MANDATORY: OpenSSH Public key'
|
112
|
+
|
113
|
+
EQUALITY octetStringMatch
|
114
|
+
|
115
|
+
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
|
116
|
+
|
117
|
+
olcObjectClasses: ( 1.3.6.1.4.1.24552.500.1.1.2.0 NAME 'ldapPublicKey' SUP top AUXILIARY
|
118
|
+
|
119
|
+
DESC 'MANDATORY: OpenSSH LPK objectclass'
|
120
|
+
|
121
|
+
MAY ( sshPublicKey $ uid )
|
122
|
+
|
123
|
+
)
|
124
|
+
|
125
|
+
```
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
ldappサーバーから公開鍵を取得する設定(クライアント側)
|
130
|
+
|
131
|
+
・AuthorizedKeysCommandを使用
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
/etc/ssh/sshd_config
|
136
|
+
|
137
|
+
```lang
|
138
|
+
|
139
|
+
AuthorizedKeysCommand /usr/lib/ssh-command/find_key.sh
|
140
|
+
|
141
|
+
AuthorizedKeysCommandUser root
|
142
|
+
|
143
|
+
```
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
/usr/lib/ssh-command/find_key.sh
|
148
|
+
|
149
|
+
```lang
|
150
|
+
|
151
|
+
#!/bin/bash
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
uri=ldap://10.0.XXX.XXX/
|
156
|
+
|
157
|
+
binddn="cn=admin,dc=example,dc=co,dc=jp"
|
158
|
+
|
159
|
+
bindpw=******
|
160
|
+
|
161
|
+
base="dc=example,dc=co,dc=jp"
|
162
|
+
|
163
|
+
uid=$1
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
ldapsearch -LLL -H ${uri} -w "${bindpw}" -D "${binddn}" -b "${base}" "(& (objectClass=posixAccount) (uid=${uid}))" "sshPublicKey" | ruby -e 'puts STDIN.read.gsub(/\n /,"").match(/sshPublicKey: (.+)/).to_a[1]'
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
※クライアント側から上記/usr/lib/ssh-command/find_key.shに引数ユーザー名を渡して実行した結果、公開鍵情報は取得できています。
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
```lang
|
176
|
+
|
177
|
+
/usr/lib/ssh-command/find_key.sh username
|
178
|
+
|
179
|
+
ssh-rsa AAAA*********・・・
|
180
|
+
|
181
|
+
```l
|