Enabling ssh through uploading a PHP script (Network space 2)

Use the following script to enable the ssh daemon and add your public key to the authorized_keys file. If you get a 404 when you try to access this script then your firmware is too updated for this hack (probably 1.2.6 or newer).

<?php /******************************************************	* Enable SSH root access on Lacie Network Space 2 (v1.0.2 & v1.2.5) *	* - Use puttygen to create a public/private key pair * - Save the public and private key to your computer * - Copy the key from the puttygen box "Public key for pasting into OpenSSH authorized_keys file" * - Paste the key into this script in the $sshkey variable below. * - Save this script (call it ssh.php) to the OpenShare of your Network Space 2 (\\\OpenShare) * - Open a brower and point it to the following URL: *  http:///webdav/OpenShare/ssh.php * - Restart the Network Space 2 * - Tell PuTTY to use your private key to connect to the Network Space 2 * - You should be able to log in as root *	******************************************************/	$sshkey=''; // Paste your key here. It starts with ssh-rsa (or ssh-dss) and ends with your "Key comment" /******************************************************	// No changes needed below this line ******************************************************/	if (empty($sshkey)) { die("Please paste your public key into this script!!"); }	$runlevelpath = '/etc/initng/runlevel/default.runlevel'; $authorizedkeyspath = '/root/.ssh/authorized_keys'; $initngfile = file ($runlevelpath, FILE_IGNORE_NEW_LINES); if (in_array('sshd',$initngfile)) { echo "SSH already enabled "; } else { echo "Enabling SSH Access "; $fh = fopen($runlevelpath, 'a'); fwrite($fh, "sshd\n"); fclose($fh); }	if (!is_dir('/root/.ssh')) { echo "Creating directory /root/.ssh "; mkdir('/root/.ssh'); }	if (file_exists($authorizedkeyspath)) { $authkeys = file('/root/.ssh/authorized_keys', FILE_IGNORE_NEW_LINES); } else { $authkeys = Array; //suppress warning }	if (!in_array($sshkey,$authkeys)) { echo "Adding your public key to /root/.ssh/authorized_keys "; $fh = fopen('/root/.ssh/authorized_keys', 'a'); fwrite($fh, $sshkey."\n"); fclose($fh); } else { echo "Your public key is already in /root/.ssh/authorized_keys "; }	echo "Please restart your device";

?>