| File inc/keys.inc.php changed (mode: 100644) (index 31381da..44f519f) |
| ... |
... |
function rg_keys_event_notify_user($db, $event) |
| 131 |
131 |
return $ret; |
return $ret; |
| 132 |
132 |
} |
} |
| 133 |
133 |
|
|
|
134 |
|
/* |
|
135 |
|
* Returns TRUE if the key is too weak by the admin standards |
|
136 |
|
* @ki - output of rg_keys_info() |
|
137 |
|
*/ |
|
138 |
|
function rg_keys_weak($db, $ki) |
|
139 |
|
{ |
|
140 |
|
$ret = array('ok' => 0, 'weak' => 1); |
|
141 |
|
|
|
142 |
|
if (strcmp($ki['type'], 'ssh-rsa') == 0) { |
|
143 |
|
$min = rg_state_get($db, 'ssh_key_min_bits_rsa'); |
|
144 |
|
if ($min === FALSE) { |
|
145 |
|
rg_keys_set_error('cannot lookup state'); |
|
146 |
|
return $ret; |
|
147 |
|
} |
|
148 |
|
if ($ki['bits'] < $min) { |
|
149 |
|
rg_keys_set_error('RSA key has less than ' |
|
150 |
|
. $min . ' bits (' . $ki['bits'] . ')'); |
|
151 |
|
$ret['ok'] = 1; |
|
152 |
|
return $ret; |
|
153 |
|
} |
|
154 |
|
} else if (strcmp($ki['type'], 'ssh-dss') == 0) { |
|
155 |
|
$r = rg_state_get($db, 'ssh_key_allow_dsa'); |
|
156 |
|
if ($r === FALSE) { |
|
157 |
|
rg_keys_set_error('cannot lookup state'); |
|
158 |
|
return $ret; |
|
159 |
|
} |
|
160 |
|
if ($r != 1) { |
|
161 |
|
rg_keys_set_error('DSA keys are not allowed'); |
|
162 |
|
$ret['ok'] = 1; |
|
163 |
|
return $ret; |
|
164 |
|
} |
|
165 |
|
} else if (strncmp($ki['type'], 'ecdsa-', 6) == 0) { |
|
166 |
|
$min = rg_state_get($db, 'ssh_key_min_bits_ecdsa'); |
|
167 |
|
if ($min === FALSE) { |
|
168 |
|
rg_keys_set_error('cannot lookup state'); |
|
169 |
|
return $ret; |
|
170 |
|
} |
|
171 |
|
if ($ki['bits'] < $min) { |
|
172 |
|
rg_keys_set_error('ECDSA key has less than ' |
|
173 |
|
. $min . ' bits (' . $ki['bits'] . ')'); |
|
174 |
|
$ret['ok'] = 1; |
|
175 |
|
return $ret; |
|
176 |
|
} |
|
177 |
|
} |
|
178 |
|
|
|
179 |
|
$ret['ok'] = 1; |
|
180 |
|
$ret['weak'] = 0; |
|
181 |
|
return $ret; |
|
182 |
|
} |
|
183 |
|
|
| 134 |
184 |
/* |
/* |
| 135 |
185 |
* Extracts info about a ssh key |
* Extracts info about a ssh key |
| 136 |
186 |
*/ |
*/ |
| |
| ... |
... |
function rg_keys_add($db, $ui, $key) |
| 423 |
473 |
break; |
break; |
| 424 |
474 |
|
|
| 425 |
475 |
$r = rg_keys_weak($db, $ki); |
$r = rg_keys_weak($db, $ki); |
|
476 |
|
if ($r['ok'] != 1) |
|
477 |
|
break; |
| 426 |
478 |
if ($r['weak'] != 0) |
if ($r['weak'] != 0) |
| 427 |
479 |
break; |
break; |
| 428 |
480 |
|
|
| |
| ... |
... |
function rg_keys_regen($db) |
| 697 |
749 |
|
|
| 698 |
750 |
$errors = 0; |
$errors = 0; |
| 699 |
751 |
foreach ($list as $row) { |
foreach ($list as $row) { |
|
752 |
|
// Ignore invalid keys |
|
753 |
|
$ki = rg_keys_info($row['key']); |
|
754 |
|
if ($ki['ok'] != 1) |
|
755 |
|
continue; |
|
756 |
|
|
|
757 |
|
// Ignore weak keys |
|
758 |
|
$r = rg_keys_weak($db, $ki); |
|
759 |
|
if ($r['ok'] != 1) |
|
760 |
|
continue; |
|
761 |
|
if ($r['weak'] != 0) |
|
762 |
|
continue; |
|
763 |
|
|
| 700 |
764 |
//rg_log("Writing key [" . $row['key'] . "] for uid " . $row['uid']); |
//rg_log("Writing key [" . $row['key'] . "] for uid " . $row['uid']); |
| 701 |
765 |
$buf = rg_keys_output_line($row); |
$buf = rg_keys_output_line($row); |
|
766 |
|
|
| 702 |
767 |
if (@fwrite($f, $buf) === FALSE) { |
if (@fwrite($f, $buf) === FALSE) { |
| 703 |
768 |
rg_keys_set_error("cannot write; disk space problems? ($php_errormsg)"); |
rg_keys_set_error("cannot write; disk space problems? ($php_errormsg)"); |
| 704 |
769 |
$errors = 1; |
$errors = 1; |
| |
| ... |
... |
function rg_keys_list($db, $ui) |
| 755 |
820 |
continue; |
continue; |
| 756 |
821 |
} |
} |
| 757 |
822 |
|
|
|
823 |
|
$r = rg_keys_weak($db, $ki); |
|
824 |
|
if ($r['ok'] != 1) |
|
825 |
|
continue; |
|
826 |
|
$ki['weak'] = $r['weak']; |
|
827 |
|
|
| 758 |
828 |
$t = $ki; |
$t = $ki; |
| 759 |
829 |
$t['key_id'] = $row['key_id']; |
$t['key_id'] = $row['key_id']; |
| 760 |
830 |
if ($row['itime'] == 0) |
if ($row['itime'] == 0) |
| |
| ... |
... |
function rg_keys_search_by_fingerprint($db, $fp) |
| 845 |
915 |
return $ret; |
return $ret; |
| 846 |
916 |
} |
} |
| 847 |
917 |
|
|
| 848 |
|
/* |
|
| 849 |
|
* Returns TRUE if the key is too weak by the admin standards |
|
| 850 |
|
* @ki - output of rg_keys_info() |
|
| 851 |
|
*/ |
|
| 852 |
|
function rg_keys_weak($db, $ki) |
|
| 853 |
|
{ |
|
| 854 |
|
$ret = array('ok' => 0, 'weak' => 1); |
|
| 855 |
|
|
|
| 856 |
|
if (strcmp($ki['type'], 'ssh-rsa') == 0) { |
|
| 857 |
|
$min = rg_state_get($db, 'ssh_key_min_bits_rsa'); |
|
| 858 |
|
if ($min === FALSE) { |
|
| 859 |
|
rg_keys_set_error('cannot lookup state'); |
|
| 860 |
|
return $ret; |
|
| 861 |
|
} |
|
| 862 |
|
if ($ki['bits'] < $min) { |
|
| 863 |
|
rg_keys_set_error('RSA key has less than ' |
|
| 864 |
|
. $min . ' bits (' . $ki['bits'] . ')'); |
|
| 865 |
|
$ret['ok'] = 1; |
|
| 866 |
|
return $ret; |
|
| 867 |
|
} |
|
| 868 |
|
} else if (strcmp($ki['type'], 'ssh-dss') == 0) { |
|
| 869 |
|
$r = rg_state_get($db, 'ssh_key_allow_dsa'); |
|
| 870 |
|
if ($r === FALSE) { |
|
| 871 |
|
rg_keys_set_error('cannot lookup state'); |
|
| 872 |
|
return $ret; |
|
| 873 |
|
} |
|
| 874 |
|
if ($r != 1) { |
|
| 875 |
|
rg_keys_set_error('DSA keys are not allowed'); |
|
| 876 |
|
$ret['ok'] = 1; |
|
| 877 |
|
return $ret; |
|
| 878 |
|
} |
|
| 879 |
|
} else if (strncmp($ki['type'], 'ecdsa-', 6) == 0) { |
|
| 880 |
|
$min = rg_state_get($db, 'ssh_key_min_bits_ecdsa'); |
|
| 881 |
|
if ($min === FALSE) { |
|
| 882 |
|
rg_keys_set_error('cannot lookup state'); |
|
| 883 |
|
return $ret; |
|
| 884 |
|
} |
|
| 885 |
|
if ($ki['bits'] < $min) { |
|
| 886 |
|
rg_keys_set_error('ECDSA key has less than ' |
|
| 887 |
|
. $min . ' bits (' . $ki['bits'] . ')'); |
|
| 888 |
|
$ret['ok'] = 1; |
|
| 889 |
|
return $ret; |
|
| 890 |
|
} |
|
| 891 |
|
} |
|
| 892 |
|
|
|
| 893 |
|
$ret['ok'] = 1; |
|
| 894 |
|
$ret['weak'] = 0; |
|
| 895 |
|
return $ret; |
|
| 896 |
|
} |
|
| 897 |
|
|
|
| 898 |
918 |
?> |
?> |
| File root/themes/default/hints/ssh/key.html changed (mode: 100644) (index cf9a1fc..f6491be) |
| 1 |
1 |
<br /> |
<br /> |
|
2 |
|
Keys marked with <span style="background-color: #f00; padding: 2pt">red</span> |
|
3 |
|
are disabled by the admin because are too weak. |
|
4 |
|
They cannot by used anymore and should be deleted.<br /> |
|
5 |
|
<br /> |
|
6 |
|
|
| 2 |
7 |
How to create a SSH key for RocketGit:<br /> |
How to create a SSH key for RocketGit:<br /> |
| 3 |
8 |
<div class="xcode"> |
<div class="xcode"> |
| 4 |
9 |
cd; mkdir -p .ssh; chmod go= .ssh<br /> |
cd; mkdir -p .ssh; chmod go= .ssh<br /> |
| |
| ... |
... |
Now, copy in clipboard starting with "ssh-...", including the comment |
| 11 |
16 |
and paste it in the form above. Do not worry about spaces or wrapping.<br /> |
and paste it in the form above. Do not worry about spaces or wrapping.<br /> |
| 12 |
17 |
<br /> |
<br /> |
| 13 |
18 |
|
|
| 14 |
|
To force the use of this key when you connect to the server,<br /> |
|
|
19 |
|
To force the use of this key when you connect to the server, |
| 15 |
20 |
add the following lines to your ~/.ssh/config (use tab key to indent):<br /> |
add the following lines to your ~/.ssh/config (use tab key to indent):<br /> |
| 16 |
21 |
<div class="xcode"> |
<div class="xcode"> |
| 17 |
22 |
Host @@rg_ssh_host@@<br /> |
Host @@rg_ssh_host@@<br /> |