Sunday 12 May 2013

Connecting to the SailfishOS VMs with WinSCP

Introduction

Note: This post will be updated for the Qt5 Alpha shortly!

Ever get fed up with navigating through unix directory structures on the command line? Having to type PWD because you have forgotten exactly where you are?
Do you need to transfer files from your localhost to your VMs?

Well if you are running in on Windows you are in luck: Meet WinSCP

For those who don't know WinSCP, it's an excellent File Transfer tool in the style of 
Norton Commander / Total Commander. It is one of the easiest ways of transferring files from Windows to Unix, and for navigating a remote Unix instance.

This is a guide to setting up WinSCP to connect to Sailfish SDK and Emulator, and in particular how to modify the RSA keys so that this is possible.



Step 1: generate the private and public key

Our first challenge, is that out-of-the-box the SailfishOS authentication keys don't work with WinSCP / Putty. But we can fix that by adding Putty friendly keys to the key files.


In PuttyGen (bundled with WinSCP)
1) Choose SSH-2 RSA 2048 bit

2) Click Generate
3) Doodle around with you mouse when instructed (and keep doodling until the key is generated)

Step 2: Save the private key

1) Hit the button save private key.
2) Choose a suitable name and location, I put mine in the same directory Sailfish uses: C:\Users\<your user directory here>\.ssh\SailfishOs.ppk
This is the key that you will use from WinSCP to connect to both the SDK and Emulator.

Step 3: Append the new public key to the 4 authorized_key files:

1) Copy the public key from the box at the top of the screen, making sure you get the whole thing (on my first attempt I only got part of it ...)
2) The key should start with "ssh-rsa " and end with "== rsa-key-YYYYMMDD" where YYYYMMDD is the current date.
3) Open the 4 files below, and paste the key on a new line (i.e. append to existing content). These files will now have two keys, the existing, and your new one.
  • C:\SailfishOS\mersdk\ssh\root\authorized_keys
  • C:\SailfishOS\mersdk\ssh\mersdk\authorized_keys
  • C:\SailfishOS\emulator\ssh\nemo\authorized_keys
  • C:\SailfishOS\emulator\ssh\root\authorized_keys
4) Save all 4 files.

Step 4: Connecting from WinSCP to the SDK:

1) Open WinSCP and setup a new session: 
  • File Protocol: SCPHostname: localhost
  • Port number: 2222
  • Private key file: C:\Users\<your user directory here>\.ssh\SailfishOs.ppk
2) Hit Save and choose a suitable name (e.g. "Sailfish root MERSDK")
3) Hit Login to connect.

Step 5: Connecting from WinSCP to the Emulator: 

1) As for Step 4, using port 2223

Have fun

No comments:

Post a Comment