Key generation

Raspberry Pi configuration guide to use SSH Key authentication with the RaspController application

RaspController for iOS only supports the RSA key.

To generate new RSA SSH key type the following command in the Raspberry Pi terminal:

ssh-keygen -t rsa -m PEM

confirms the name of the file with ENTER and enter a passphrase (recommended).

 

 

If you don’t use any passphrase you need to edit the file /etc/ssh/sshd_config with 'PermitEmptyPasswords yes'.

SSH


Edit the file ‘sshd_config’:

sudo nano /etc/ssh/sshd_config

edit the line ‘AuthorizedKeysFile’ removing the # symbol (if present) and adding:

.ssh/id_rsa.pub

 

Save the content of the file pressing CTRL + X (to exit from nano), respond “Yes” at the request of saving, then confirm with ENTER.

Now reboot the ssh service with:

sudo /etc/init.d/ssh restart

or reboot the Raspberry Pi.

RaspController


Add a new device into the RaspController application and copy the ‘id_rsa’ file content generated by the Raspberry Pi.

Only for user other than 'pi'


If you are using a user other than the classic ‘pi’ remove the password prompt from this user.

Create a custom sudoers file using (replace bob with your user):

sudo visudo /etc/sudoers.d/010_bob-nopasswd

Insert the following contents on a single line:

bob ALL=(ALL) NOPASSWD: ALL

Save the file and exit.

 

Raspberry Pi documentation: https://www.raspberrypi.org/documentation/linux/usage/users.md

Only for root user


The previously created keys are placed in the ‘pi’ user folder, now you also need to copy the public key in the root directory.

Create the ssh directory (if not exists) [~ is Alt Gr + ì]:

sudo mkdir ~root/.ssh

Copy the key:

sudo cp ~/.ssh/id_rsa.pub ~root/.ssh/id_rsa.pub