Package: rk
Table of contentsInstallationInstall the rk from PyPIInstall the rk from GitHubUpgrade the rk from PyPIUninstall the rkDevelopment installationQuickstartUser guideHelpVersionKernels dictKernels locationShow list of remote jupyter kernels from kernels dictInstall a remote jupyter kernel/kernels from kernels dict to kernels locationInstall a template of a remote jupyter kernel to kernels locationInstall all remote jupyter kernels from kernels dict to kernels locationUninstall a remote jupyter kernel/kernels from kernels locationUninstall a template of a remote jupyter kernel from kernels locationUninstall all jupyter kernels from kernels locationSetup SSH for auto login without a passwordLog filesHistoryLegendrk 0.3rk 0.2InstallationInstall the rk from PyPI$ sudo pip install rkInstall the rk from GitHub$ sudo pip install git+git://github.com/korniichuk/rk#egg=rkUpgrade the rk from PyPI$ sudo pip install -U rkor:$ sudo pip install --upgrade rkImportantThe rk set to dafault thekernels dictkernels.json. Save the currentkernels dictto home dir before upgrade, and replace defaultkernels dictfile after.Uninstall the rk$ sudo pip uninstall rkDevelopment installation$ git clone git://github.com/korniichuk/rk.git
$ cd rk
$ sudo pip install .QuickstartFirst, make sure that you can login to a remote machine without entering password. The most basic form of the command is:$ ssh REMOTE_HOSTIf your username is different on a remote machine, you can specify it by using this syntax:$ ssh REMOTE_USERNAME@REMOTE_HOSTExample:$ ssh albert@192.168.0.1NoteYou cansetup SSH for auto login without a passwordlike this:$ rk ssh.Second, install a template of a remote jupyter kernel tokernels location:$ rk install-templateThird, change thekernel.jsonfile:$ sudo gedit /usr/local/share/jupyter/kernels/template/kernel.jsonThekernel.jsonfile looks like this:{
 "argv": [
  "rkscript",
  "python",
  "{connection_file}",
  "remote_username@remote_host"
 ],
 "display_name": "Template",
 "language": "python"
}For a python2 remote jupyter kernel just changeremote_username@remote_host. For example fromremote_username@remote_hosttoalbert@192.168.0.1.Fourth, launch jupyter notebook and check your new remote juputer kernel:$ jupyter notebookor:$ ipython notebookChoose:Files->New->Template.User guideHelpThe standard output for –help:$ rk -hor:$ rk --helpFor information on using subcommand “SUBCOMMAND”, do:$ rk SUBCOMMAND -hor:$ rk SUBCOMMAND --helpExample:$ rk install -hVersionThe standard output for –version:$ rk -vor:$ rk --versionKernels dictOpenkernels.jsonfile:$ sudo gedit /usr/local/lib/python2.7/dist-packages/rk/config/kernels.jsonThekernels.jsonfile looks like this:{
 "template": {
  "display_name": "Template",
  "interpreter": "python",
  "language": "python",
  "remote_host": "remote_username@remote_host"
 }
}Where:template– the name of a remote jupyter kernel,display_name– a kernel’s name as it should be displayed in the UI. Unlike the kernel name used in the API, this can contain arbitrary unicode characters[1],interpreter– an entry point or an absolute path to language interpreter on a remote machine,language– a name of the language of a kernel. When loading notebooks, if no matching kernelspec key (may differ across machines) is found, a kernel with a matching language will be used. This allows a notebook written on any python or julia kernel to be properly associated with the user’s python or julia kernel, even if they aren’t listed under the same name as the author’s[1],remote_host– just a remote host or, if your username is different on a remote machine, use this syntax: remote username AT remote host.NoteFor checking absolute path to language interpreter on a remote machine use awhichUnix command. For example, for the python3 language on a remote machine:$ which python3.Changekernels.jsonfile and add info about your remote jupyter kernels, for example like this:{
 "albert2": {
  "display_name": "Albert Python 2",
  "interpreter": "python2",
  "language": "python",
  "remote_host": "albert@192.168.0.1"
 },
 "albert3": {
  "display_name": "Albert Python 3",
  "interpreter": "python3",
  "language": "python",
  "remote_host": "albert@192.168.0.1"
 }
}Where:albert2,albert3– the names of a remote jupyter kernels,Albert Python 2,Albert Python 3– the display names for the UI,python2,python3– entry points on a remote machine,python– the name of the language of a remote jupyter kernel,albert– the remote username on a remote machine, not similar with a username on a local machine,192.168.0.1– the remote host.Kernels locationJupyter support the system and the userkernels locations:kernels locationsystem/usr/local/share/jupyter/kernels;/usr/share/jupyter/kernelsuser~/.ipython/kernelsThe default kernels location in the rk:/usr/local/share/jupyter/kernels.Change the default kernels location:$ sudo gedit /usr/local/lib/python2.7/dist-packages/rk/config/rk.iniImportantThe user kernels location takes priority over the system kernels locations.Show list of remote jupyter kernels from kernels dict$ rk listInstall a remote jupyter kernel/kernels from kernels dict to kernels location$ rk install KERNEL_NAME [KERNEL_NAME ...]Where:KERNEL_NAME– a name of a remote jupyter kernel in thekernels dictkernels.json.Example:$ rk install albert2
$ rk install albert2 albert3Install a template of a remote jupyter kernel to kernels location$ rk install-templateImportantAfter this subcommand open thekernel.jsonfile and change values of dict:$ sudo gedit /usr/local/share/jupyter/kernels/template/kernel.json.Install all remote jupyter kernels from kernels dict to kernels location$ rk install-allUninstall a remote jupyter kernel/kernels from kernels location$ rk uninstall KERNEL_NAME [KERNEL_NAME ...]Where:KERNEL_NAME – a name of installed remote jupyter kernel.Example:$ rk uninstall albert2
$ rk uninstall albert2 albert3Uninstall a template of a remote jupyter kernel from kernels location$ rk uninstall-templateUninstall all jupyter kernels from kernels location$ rk uninstall-allSetup SSH for auto login without a password$ rk sshIf you are familiar withssh-keygen,ssh-copy-idandssh-add, this code also setup SSH for auto login without a password[2]:$ ssh-keygen -t rsa -b 4096 -N '' -f ~/.ssh/id_rsa
$ ssh-copy-id REMOTE_HOST
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsaNoteIf your username is different on a remote machine, you can specify it by using this syntax:$ssh-copy-idREMOTE_USERNAME@REMOTE_HOST.Log filesThe default log files location in the rk:/tmp/rk/log. The name of rk log file, for working remote jupyter kernel, look like this:bree@192.168.0.1_1879-03-14_11.30.00.txt. And the log file looks like this:date: 1879-03-14 Friday
time: 11:30:00

usernames: bree<->albert
remote host: 192.168.0.1

stdin ports: 37654<->58933
hb ports: 53538<->59782
iopub ports: 45330<->51989
shell ports: 36523<->36107
control ports: 50090<->53633

pids: 16965<->20944NoteChange the default log files location:$ sudo gedit/usr/local/lib/python2.7/dist-packages/rk/config/rk.ini.The paramiko log file is available in a local connection file directory. The name of paramiko log file, for working remote jupyter kernel, look like this:paramiko-843664c7-798d-4a9e-979c-22d0dc4a6bd5.txt.HistoryLegendaddedcorrectedremovedrk 0.3bug in the rk and in the rkscript: an initial component of~or~useris not replaced in a paths.bug in the rk: a superuser (root) privileges required for the user kernels location~/.ipython/kernels.setup SSH for auto login without a password with a “ssh” subcommand.error in the rkscript: list index out of range.info about working remote jupyter kernel in rk log file.paramiko log file in a local connection file dir.error in the rkscript: no handlers could be found for logger “paramiko.transport”.local port forwarding in the rkscript via paramiko, not via pexpect.rk 0.2uninstall all jupyter kernels from kernels location with a “uninstall-all” subcommand.uninstall a remote jupyter kernel/kernels from kernels location with a “uninstall” subcommand.install a remote jupyter kernel/kernels from kernels dict to kernels location with a “install” subcommand.install all remote jupyter kernels from kernels dict to kernels location with a “install-all” subcommand.show list of remote jupyter kernels from kernels dict with a “list” subcommand.Footnotes[1](1,2)http://ipython.org/ipython-doc/dev/development/kernels.html#kernel-specs[2]https://help.github.com/articles/generating-ssh-keys/