Saturday 11 May 2013

Connecting to the SailfishOS SDK and Emulator

Introduction

02 Aug 2013: Adapted for Qt5 Alpha

At some time you will want to get into the heart of the SDK and Emulators. maybe you: 

  • need to install additional packages
  • need to change some settings
  • move some files around
  • have to manually deploy or deinstall your app
  • or are just nosy, and like a small boy delight in taking things apart to find out how they work.

There are two ways to do this:

  • opening a terminal directly on the GUI of the virtual machines. I will call this VM terminal.
  • connecting via SSH from a terminal session on your local host.
In both cases you will working in a unix shell, and be able to do much the same thing. On the whole I have found it better to use the SSH from local host root because:
  • the local terminal uses my local keyboard settings, the VM terminals do not, and trying to figure out half way through a long unix command how to type US special symbols with a Swiss keyboard does not help speed up typing!
  • you can't scroll up in the VM terminal sessions - this forces you to have to pipe commands like ls to more
However there are times where SSH does not work (more on this later). In that case the VM terminal approach is a godsend.


Users

SDK: We have several users,  used for both ways of connecting,
 
Qt 4.8.3 SDK
user root password rootme
user mersdk password ?????

Qt 5 SDK
user root password not required
user mersdk password ?????
user nemo password nemo


Emulator: We also have 2 users, again useable for both ways

Qt 4.8.3 Emulator
user root password nemo
user nemo password nemo

Qt 5 Emulator
user root password not required
user nemo password nemo

 

Connecting using the VM Terminal:

If you are wise enough not to use a Mac to do this; then on either of the VMs hit right-ctrl-F2 to get a login prompt, and use the user / passwords above.

However if like me you are using a Mac you could be faced with 2 problems:

  • Mac function keys don't automatically work as function keys!: To fix this go to "System Preferences / Keyboard / Keyboard" and check "Use all F1, F2, etc. as standard function keys"
  • You may not have a right-ctrl key! While Butschgi my Mac Pro tTower does, Apple-pip my MacBook Air does not! In this case the host key will be left-cmd, or what ever is indicated at the bottom right of the VM status bar.

 

Connecting using SSH from your localhost:

If you are running Linux or OSX, then you will have SSH already available. If you are on Windows, then either download Putty, or WinSCP - which also includes Putty and gives you a Norton Commander style Secure Copy File manager  - more of which in another post.

We will connect using the key mer-qt-creator-rsa.

To do so, we first need to make sure that the public part of the mer-qt-creator-rsa pair is in the authorised key files on the SDK and Emulator VMs.

First find the public key

/Users/<yourhomedrive>/.ssh/mer-qt-creator-rsa.pub

 Then find and open the mersdk authorised_keys for the user root:

/Users/<yourhomedrive>/SailfishOSAlpha5/mersdk/ssh/root/authorized_keys

If necessary, append the contents of the public key file to the authorised keys file. 

Repeat with

/Users/<yourhomedrive>/SailfishOSAlpha5/mersdk/ssh/mersdk/authorized_keys

/Users/<yourhomedrive>/SailfishOSAlpha5/emulator/1/ssh/nemo/authorized_keys

/Users/<yourhomedrive>/SailfishOSAlpha5/emulator/1/ssh/root/authorized_keys


Connecting to the SDK

We will first connect as user root, then as user mersdk:

ssh -p 2222 -i ~/.ssh/mer-qt-creator-rsa  root@localhost

exit

ssh -p 2222 -i ~/.ssh/mer-qt-creator-rsa  mersdk@localhost


Connecting to the SailfishOS Emulator

We will connect first as user root, then as user memo:

ssh -p 2223  -i ~/.ssh/mer-qt-creator-rsa  root@localhost

exit

ssh -p 2222 -i ~/.ssh/mer-qt-creator-rsa  nemo@localhost


The eagle-eyed will notice that here we don't need the passwords - instead we are using the RSA key file to authenticate.

SSH Problems

Known Issues

If you cannot connect via SSH, then you first port of call should be the Alpha SDK Known Issues Page

Lubuntu

On 2 Lubuntu installations I found that SSH could not work out-of-the-box on the Emulator because the shared drive (which gives access to the RSA keys) was not being mounted.

To fix this I connected to the VM terminal and manually mounted the drive with;

mount -t vboxsf ssh /etc/ssh/authorised _keys/

And Voila! I could now SSH in from the host Lubuntu as root and nemo. So next I ventured into the dark world of fstab; The following adds an entry to fstab, ensuring automount in the future:

cd /etc
echo ssh /etc/ssh/authorized_keys vboxsf defaults 0 0 >> fstab

Have fun!

No comments:

Post a Comment