3 * Change user's SSH authorized keys
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010, Franck Villaume - Capgemini
7 * Copyright 2012, Franck Villaume - TrivialDev
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once('../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfcommon.'include/account.php';
31 if (!forge_get_config('use_shell')) {
32 exit_permission_denied();
35 session_require_login();
37 $u =& user_get_object(user_getid());
38 if (!$u || !is_object($u)) {
39 exit_error(_('Could Not Get User'),'home');
40 } elseif ($u->isError()) {
41 exit_error($u->getErrorMessage(),'my');
44 use_javascript('/js/sortable.js');
45 // not valid registration, or first time to page
46 site_user_header(array('title'=>'Manage Authorized Keys'));
47 echo '<form action="/account/?action=addsshkey" method="post">';
48 $sshKeysArray = $u->getAuthorizedKeys();
49 if (count($sshKeysArray)) {
50 echo $HTML->boxTop(_('Available keys'));
51 $tabletop = array(_('Name'), _('Algorithm'), _('Fingerprint'), _('Uploaded'), _('Ready ?'), _('Actions'));
52 $classth = array('', '', '', '', '', '', 'unsortable');
53 echo $HTML->listTableTop($tabletop, false, 'sortable_sshkeys_listlinks', 'sortable', $classth);
54 foreach($sshKeysArray as $sshKey) {
56 echo '<td>'.$sshKey['name'].'</td>';
57 echo '<td>'.$sshKey['algorithm'].'</td>';
58 echo '<td>'.$sshKey['fingerprint'].'</td>';
59 echo '<td>'.date(_('Y-m-d H:i'), $sshKey['upload']).'</td>';
60 if ($sshKey['deploy']) {
61 $image = html_image('docman/validate.png', 22, 22, array('alt'=>_('ssh key is deployed.'), 'class'=>'tabtitle', 'title'=>_('ssh key is deployed.')));
63 $image = html_image('waiting.png', 22, 22, array('alt'=>_('ssh key is not deployed yet.'), 'class'=>'tabtitle', 'title'=>_('ssh key is not deployed yet.')));
65 echo '<td>'.$image.'</td>';
66 echo '<td><a class="tabtitle-ne" href="/account/?&action=deletesshkey&keyid='.$sshKey['keyid'].'" title="'. _('Delete this ssh key.') .'" >'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Delete this ssh key.'))). '</a></td>';
69 echo $HTML->listTableBottom();
70 echo $HTML->boxBottom();
73 echo '<h2>'. _('Add a new ssh key').'</h2>';
74 echo '<p>'. _('To avoid having to type your password every time for your CVS/SSH developer account, you may upload your public key(s) here and they will be placed on the server in your ~/.ssh/authorized_keys file. This is done by a cron job, so it may not happen immediately. Please allow for a one hour delay.') . '</p>';
75 echo '<p>'. _('To generate a public key, run the program \'ssh-keygen\' (you can use both protocol 1 or 2). The public key will be placed at \'~/.ssh/identity.pub\' (protocol version 1) and \'~/.ssh/id_dsa.pub\' or \'~/.ssh/id_rsa.pub\' (protocol version 2). Read the ssh documentation for further information on sharing keys.') . '</p>';
76 echo '<p>'. _('Authorized keys:<br /><em>Important: Make sure there are no line breaks. After submitting, verify that the number of keys in your file is what you expected.</em>');
79 <textarea rows="10" cols="80" name="authorized_key" style="width:90%;">
81 <p><input type="submit" name="submit" value="<?php echo _('Add'); ?>" /></p>
85 site_user_footer(array());