Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none
Accepted Solution

How to enable/connect with SSH?

The release notes for Beta3 say a new feature is "secure connection: You can now connect to the tablet using Secure Shell (SSH) and upload and download files for your application using SCP and SFTP."

 

A vanilla install does not result in the simulator listening on port 22 (the standard for SSH) or any other port for SSH connections, either with or without development mode enabled.

 

I found the blackberry-connect program in the SDK bin folder, and tried the following after creating an RSA2 key:

 

c:\>blackberry-connect -targetHost 192.168.7.172 -devicePassword x
PROGRESS: Connecting to target 192.168.7.172:4455
PROGRESS: Authenticating with target 192.168.7.172:4455
PROGRESS: Encryption parameters verified
PROGRESS: Authenticating with target credentials.
PROGRESS: Successfully authenticated with target credentials.
PROGRESS: Sending ssh key to target 192.168.7.172:4455
Connection refused: Invalid ssh key contents.
The target actively refused the connection. Please ensure that qconnDoor is running on the target.
PROGRESS: Unable to send ssh key to target

 The .ssh/id_rsa.pub file was generated as an SSH-1 key using PuttyGen.  I also tried an SSH-2 RSA file with the same results.

 

 

The fact that it says it "succesfully authenticated" suggests it successfully connected... probably using port 443 (https) the way I assume the blackberry-deploy program does.  However after that it appears to say my key is invalid (not sure I believe that), but also that the target "actively refused the connection" (I believe that... qconn is not listening on port 8000 or any other).

 

Anyone have knowledge of this area, or wild guesses I can try?


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

@taylortbb posted in the general beta 3 simulator thread, noting that qconn is in fact listening, just on port 4455.   I should have seen that from the ":4455" part in the output I showed above.

 

I realized just after I posted (but was heading up for supper) that my issue is probably that PuTTY saved the key in a Windows format rather than a more standard or at least Posix-y format. 

 

QNX would of course not be happy with the Windows format... maybe that's the issue.  I'll try converting.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

Okay, I'm able to connect using SSH.  It's a bit convoluted at the moment but I'll simplify and post a recipe as soon as I can.

 

For anyone technical enough to follow with minimal direction:

  1. I generated a 4096 bit RSA key using "ssh-keygen -b 4096" on a Linux box, saving as "test_rsa" and "test_rsa.pub"
  2. I transferred those to my Windows box.
  3. I invoked "blackberry-connect -targetHost SIMIP -devicePassword x -sshPublicKey test_rsa.pub"

This transfers the public key into the device by connecting through qconn (port 4455) using unknown protocols.  The output looks like this:

 

PROGRESS: Connecting to target 192.168.7.172:4455
PROGRESS: Authenticating with target 192.168.7.172:4455
PROGRESS: Encryption parameters verified
PROGRESS: Authenticating with target credentials.
PROGRESS: Successfully authenticated with target credentials.
PROGRESS: Sending ssh key to target 192.168.7.172:4455
PROGRESS: ssh key successfully transfered.
PROGRESS: Succesfully Connected

 The blackberry-connect program stays running, and as long as it's running at this point the simulator will be listening for SSH connections on port 22.

 

 

At this point, I had to take the test_rsa file (the private key) and import it into Puttygen using the Conversions -> Import Key menu.  Then Save private key and load that key into Pageant.

 

Finally, connect normally using PuTTY to the SIMIP address, and log in as "devuser".  This was discovered by looking in the /accounts folder using a primitive file browser app, where I found two subfolders, 1000/ and devuser/.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

Added info about connecting with SSH.  The blackberry-connect program (or, rather, whatever it talks to on the simulator side) installs your public key in /accounts/devuser/.ssh/authorized_keys2 with a "from" restriction, using the IP address of the machine on which you ran blackberry-connect.

 

This means you won't be able to connect from any other machine unless you edit that file (and you'd have to connect first from the blackberry-connect machine, and modify the file from there) either to remove that restriction or to add a second entry (could be using a different key) for the other machine.  I've verified that the former approach works, as I'd like to be able to connect (for automated testing) from a Linux machine even though I'm running my dev tools on Windows.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Contributor
Posts: 7
Registered: ‎01-12-2011
My Device: Not Specified
My Carrier: Rogers

Re: How to enable/connect with SSH?

[ Edited ]

EDIT: Ignore this post. In the time it took me to write it, the two posts above me were made... Worked like a charm Peter (I'm on OSX, so no copying or converting keys, same for Linux).

 

------------------

 

Here's how far I was able to get (after generating a 4096-bit RSA keypair with ssh-keygen):

 

Kens-iMac:bin kcampbell$ ./blackberry-connect -targetHost 192.168.45.130 -devicePassword 1234
PROGRESS: Connecting to target 192.168.45.130:4455
PROGRESS: Authenticating with target 192.168.45.130:4455
PROGRESS: Encryption parameters verified
PROGRESS: Authenticating with target credentials.
PROGRESS: Successfully authenticated with target credentials.
PROGRESS: Sending ssh key to target 192.168.45.130:4455
PROGRESS: ssh key successfully transfered.
PROGRESS: Succesfully Connected

 

 

Cheers,

Ken

 

BlackBerry Development Advisor
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: How to enable/connect with SSH?

That is very impressive Peter you figure it out without any docs - I was about to write it...

 

You need 4096 RSA key. And login is "devuser" indeed.

And all the instructions above are valid, expect keys on windows.

 

For windows you can use putty to generate them

 

Generating SSH keys on Windows

  • Run puttygen.exe
  • Select SSH2-RSA
  • Set number of bits in generated key to 4096
  • Press generate
  • Once the key is generated, provide a empty passphrase  and save your public and private key
  • Copy the text under "Public key for pasting into OpenSSH authorized_keys file" into a file. Remove any contents that appear after the last = sign. This is the file that should be passed to blackberry-connect.
Developer
Posts: 157
Registered: ‎12-16-2010
My Device: Torch 9800, PlayBook
My Carrier: I carry it myself

Re: How to enable/connect with SSH?

 


peter9477 wrote:

Okay, I'm able to connect using SSH.  It's a bit convoluted at the moment but I'll simplify and post a recipe as soon as I can.


Dude, you're good

 

----------
If you find this post helpful please "like" it and accept as a solution.
Developer
Posts: 278
Registered: ‎10-27-2010
My Device: Playbook

Re: How to enable/connect with SSH?

 


p3pp3r wrote:

 

Dude, you're good

 


Yeah, no kidding...  Robot surprised

 

 

That is not my area of expertise so I am impressed.

--------------
kdittyr

Accepted PlayBook Applications:
HDB Converter -- Utilities/Calculators
Developer
Posts: 153
Registered: ‎10-26-2010
My Device: Bold 9900
My Carrier: AT&T

Re: How to enable/connect with SSH?

[ Edited ]

Hi,

 

    I managed to connect and to start ssh (on my MacBook), but I can't read or write any files.  The attempts come back with "cannot execute - No such file or directory".  About all that works is cd, ls, and pwd.

 

EDIT: ignore this - silly me trying to transfer data using ssh instead of sftp

 

Harry

--------------
Accepted PlayBook Applications: Marmi-doos, BASIC, Run and Hide, SuperClip
Accepted OS4-7 SmartPhone App: KeepLightOn
Highlighted
Contributor
Posts: 12
Registered: ‎01-12-2011
My Device: Playbook

Re: How to enable/connect with SSH?

Hi,

 

I don't success to acces to the appData. I have my application and I would like to add image into .appData/MyApp/Local Store like on the old simulator.

 

But I have "access denied" the the appData folder.

 

I use WinSCP. But I haven't acces with putty in ssh to.

 

Any idea?

 

Thanks