zaterdag 22 augustus 2015

Howto login to OpenElec using SSH without a password.

Hi There!

For quite some time I'm using OpenElec running on a Raspberry Pi Model B version 2. It runs fine, uite fast on Model 2, but just sometimes I like to fiddle around in my RPi/OpenElec instance.

These are the steps needed to prepare for password-less login (that is: without entering a password) on OpenElec using Putty, A Free Telnet/SSH Client:

Prerequisites:



Step 1 - Create a private/public key pair

  1. start PuttyGen
  2. click Generate (to Generate a public/private key pair)
    (you have to move your mouse around quite some time for the required randomness)
    BTW: generate a SSH-2 key
  3. Now, save the generated keys in a safe place, at least the Private one
    • a Public key can (always) be regenerated through the Private key (and the passphrase, if used, which is highly recommended)
    • I name the files PrivateKey.pkk and PublicKey.pub respectively
Now, it is very important to keep in mind:
  • the PrivateKey.pkk is yours (and yours only), and is the most key 
  • the only key that really is allowed 'escaping' your system is the PublicKey.pub

Step 2 - Copy the public key to OpenElec

(I'd normally use the WinSCP program, just because it's so easy to use.
But to make this a somewhat nice tutorial on the subject of Putty, let's use Putty's Secure Copy program, PSCP)

To copy the public key to OpenElec using PSCP, you need to know

  • directory of the PSCP.EXE program that comes with Putty
  • - directory and filename
  • - IP address of the OE instance (mine is 192.168.1.18)
  • - username and  password (standard OpenElec has root as SSH-user and password openelec)


 PSCP.EXE<Directory where you put those keys>\PublicKey.pub root@<IP of OpenElec>:\.ssh

In my config/setting this means:

PSCP.EXE H:\Keys\PublicKey.pub root@192.168.x.xx:/storage/.ssh/PublicKey.pub

root@192.168.x.xx's password: [hidden] 

PublicKey.pub             | 0 kB |   0.5 kB/s | ETA: 00:00:00 | 100%

Tata! Successfully transfered!



Step 3 - Import public key to authorized_keys

  1. login to OpenElec using Putty
  2. cd to the  .ssh - directory (cd /storage/.ssh or cd ~.ssh)
  3. import the PublicKey.pub using the command
    ssh-keygen -i -f PublicKey.pub > ~/.ssh/authorized_keys
  4. cd back to /storage, using cd (or cd /storage)
  5. secure the access to the keystore, using
    chmod 700 .ssh
    chmod 600 .ssh/authorized_keys

 Step 4 - Setup Pageant and import private key

  1. on the Windows-machine, start Pageant 
  2. click the icon in the Taskbar to open Pageant
  3. click Add Key
  4. select your private (.ppk) key here,
  5. enter the Passphrase if you used one
    (in fact, I advise you to always use a passphrase, encrypting the Private Key)

 Step 5 - Start Putty

Please close all previous Putty session the OpenElec, as that could prevent the ssh-server (OpenElec) from using updated settings

  • Start Putty
  • Enter the username. 
  • If a valid (private) key is found, Pageant will serve it to Putty, and you'll have a password-less login!










Geen opmerkingen:

Een reactie posten