Skip to content

Instantly share code, notes, and snippets.

@kraeml
Created February 1, 2018 14:56
Show Gist options
  • Select an option

  • Save kraeml/438df0379a9b6c71fc931c43fa736810 to your computer and use it in GitHub Desktop.

Select an option

Save kraeml/438df0379a9b6c71fc931c43fa736810 to your computer and use it in GitHub Desktop.
rdf/ais/remote jupyter/RK Test remote jupyter.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"toc": true
},
"cell_type": "markdown",
"source": "<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Installation\" data-toc-modified-id=\"Installation-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>Installation</a></span><ul class=\"toc-item\"><li><span><a href=\"#Install-the-rk-from-PyPI\" data-toc-modified-id=\"Install-the-rk-from-PyPI-1.1\"><span class=\"toc-item-num\">1.1&nbsp;&nbsp;</span>Install the rk from PyPI</a></span></li><li><span><a href=\"#SSH-einrichten\" data-toc-modified-id=\"SSH-einrichten-1.2\"><span class=\"toc-item-num\">1.2&nbsp;&nbsp;</span>SSH einrichten</a></span></li><li><span><a href=\"#Testmaschine\" data-toc-modified-id=\"Testmaschine-1.3\"><span class=\"toc-item-num\">1.3&nbsp;&nbsp;</span>Testmaschine</a></span></li><li><span><a href=\"#RK-einrichten\" data-toc-modified-id=\"RK-einrichten-1.4\"><span class=\"toc-item-num\">1.4&nbsp;&nbsp;</span>RK einrichten</a></span></li></ul></li></ul></div>"
},
{
"metadata": {},
"cell_type": "markdown",
"source": "# Installation\n\n## Install the rk from PyPI\n\nZunächst rk via pip installieren.\n"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo pip install rk",
"execution_count": 1,
"outputs": [
{
"text": "\u001b[33mThe directory '/home/vagrant/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.\u001b[0m\n\u001b[33mThe directory '/home/vagrant/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.\u001b[0m\nCollecting rk\n Downloading rk-0.3b1.tar.gz (141kB)\n\u001b[K 100% |████████████████████████████████| 143kB 1.6MB/s ta 0:00:01\n\u001b[?25hCollecting configobj (from rk)\n Downloading configobj-5.0.6.tar.gz\nRequirement already satisfied: execnet in /usr/local/lib/python3.5/dist-packages (from rk)\nCollecting paramiko (from rk)\n Downloading paramiko-2.4.0-py2.py3-none-any.whl (192kB)\n\u001b[K 100% |████████████████████████████████| 194kB 1.4MB/s ta 0:00:01\n\u001b[?25hRequirement already satisfied: six in /usr/local/lib/python3.5/dist-packages (from configobj->rk)\nRequirement already satisfied: apipkg>=1.4 in /usr/local/lib/python3.5/dist-packages (from execnet->rk)\nCollecting bcrypt>=3.1.3 (from paramiko->rk)\n Downloading bcrypt-3.1.4-cp35-cp35m-manylinux1_x86_64.whl (54kB)\n\u001b[K 100% |████████████████████████████████| 61kB 2.5MB/s ta 0:00:011\n\u001b[?25hCollecting pynacl>=1.0.1 (from paramiko->rk)\n Downloading PyNaCl-1.2.1-cp35-cp35m-manylinux1_x86_64.whl (692kB)\n\u001b[K 100% |████████████████████████████████| 696kB 887kB/s ta 0:00:01\n\u001b[?25hCollecting cryptography>=1.5 (from paramiko->rk)\n Downloading cryptography-2.1.4-cp35-cp35m-manylinux1_x86_64.whl (2.2MB)\n\u001b[K 100% |████████████████████████████████| 2.2MB 421kB/s ta 0:00:011\n\u001b[?25hCollecting pyasn1>=0.1.7 (from paramiko->rk)\n Downloading pyasn1-0.4.2-py2.py3-none-any.whl (71kB)\n\u001b[K 100% |████████████████████████████████| 71kB 2.2MB/s ta 0:00:011\n\u001b[?25hCollecting cffi>=1.1 (from bcrypt>=3.1.3->paramiko->rk)\n Downloading cffi-1.11.4-cp35-cp35m-manylinux1_x86_64.whl (419kB)\n\u001b[K 100% |████████████████████████████████| 419kB 1.1MB/s ta 0:00:01\n\u001b[?25hCollecting asn1crypto>=0.21.0 (from cryptography>=1.5->paramiko->rk)\n Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)\n\u001b[K 100% |████████████████████████████████| 102kB 1.9MB/s a 0:00:011\n\u001b[?25hRequirement already satisfied: idna>=2.1 in /usr/local/lib/python3.5/dist-packages (from cryptography>=1.5->paramiko->rk)\nCollecting pycparser (from cffi>=1.1->bcrypt>=3.1.3->paramiko->rk)\n Downloading pycparser-2.18.tar.gz (245kB)\n\u001b[K 100% |████████████████████████████████| 256kB 1.6MB/s ta 0:00:01\n\u001b[?25hInstalling collected packages: configobj, pycparser, cffi, bcrypt, pynacl, asn1crypto, cryptography, pyasn1, paramiko, rk\n Running setup.py install for configobj ... \u001b[?25ldone\n\u001b[?25h Running setup.py install for pycparser ... \u001b[?25ldone\n\u001b[?25h Running setup.py install for rk ... \u001b[?25ldone\n\u001b[?25hSuccessfully installed asn1crypto-0.24.0 bcrypt-3.1.4 cffi-1.11.4 configobj-5.0.6 cryptography-2.1.4 paramiko-2.4.0 pyasn1-0.4.2 pycparser-2.18 pynacl-1.2.1 rk-0.3b1\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## SSH einrichten\n\nEinen pasphrasse less key erzeugen. Achtung id_rsa wird gelöscht."
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "rk ssh",
"execution_count": 2,
"outputs": [
{
"text": "Generating public/private rsa key pair.\nYour identification has been saved in /home/vagrant/.ssh/id_rsa.\nYour public key has been saved in /home/vagrant/.ssh/id_rsa.pub.\nThe key fingerprint is:\nSHA256:rWnJRlKEwiQAP1t8mkpEG4ob+E5ql+OT1O1ECxjfBGs vagrant@rdf-dev\nThe key's randomart image is:\n+---[RSA 4096]----+\n|+.+o..... |\n|o+ *o oo |\n|= = *E+ . |\n| = =.* + . |\n|. = + = S . |\n| = o.. B + |\n|..++. o B |\n|. oo. + |\n| .. |\n+----[SHA256]-----+\nEnter REMOTE_HOST (with optional REMOTE_USERNAME: REMOTE_USERNAME@REMOTE_HOST):\nTraceback (most recent call last):\n File \"/usr/local/bin/rk\", line 11, in <module>\n load_entry_point('rk==0.3b1', 'console_scripts', 'rk')()\n File \"/usr/local/lib/python3.5/dist-packages/rk/rk.py\", line 255, in main\n args.function_name(args)\n File \"/usr/local/lib/python3.5/dist-packages/rk/rk.py\", line 352, in setup_ssh_auto_login\n remote_username_at_remote_host = raw_input()\nNameError: name 'raw_input' is not defined\n",
"name": "stdout",
"output_type": "stream"
},
{
"ename": "",
"traceback": [],
"evalue": "1",
"output_type": "error"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## Testmaschine\n\nEine lxc Testmaschine einrichten."
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo lxc-create -t ubuntu -n remoteJupyter",
"execution_count": 3,
"outputs": [
{
"text": "The configuration file contains legacy configuration keys.\nPlease update your configuration file!\nThe update script lxc-update-config -c <path-to-config> can be used for this.\nThe configuration file contains legacy configuration keys.\nPlease update your configuration file!\nThe update script lxc-update-config -c <path-to-config> can be used for this.\nChecking cache download in /var/cache/lxc/xenial/rootfs-amd64 ... \nCopy /var/cache/lxc/xenial/rootfs-amd64 to /var/lib/lxc/remoteJupyter/rootfs ... \nCopying rootfs to /var/lib/lxc/remoteJupyter/rootfs ...\nGenerating locales (this might take a while)...\n de_DE.UTF-8... done\nGeneration complete.\ndebconf: kann Oberfläche nicht initialisieren: Dialog\ndebconf: (Die Dialog-Oberfläche funktioniert nicht auf einem Dumb-Terminal, einem Emacs-Shellbuffer oder ohne ein steuerndes Terminal.)\ndebconf: greife zurück auf die Oberfläche: Readline\ndebconf: kann Oberfläche nicht initialisieren: Readline\ndebconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)\ndebconf: greife zurück auf die Oberfläche: Teletype\nCreating SSH2 RSA key; this may take some time ...\n2048 SHA256:jWC1RtTlNAZpJ3W+MVPFwqaKp6kcaDsRUWS770JrZX8 root@rdf-dev (RSA)\nCreating SSH2 DSA key; this may take some time ...\n1024 SHA256:+Ktuwm/0bcDGXSvDXWF50DsX9ReCBFLnG2qxJfRPcE0 root@rdf-dev (DSA)\nCreating SSH2 ECDSA key; this may take some time ...\n256 SHA256:HswrcOYVcrzoxUdQvjWPFH4tXBX1fMzFV9KG2cZDAxQ root@rdf-dev (ECDSA)\nCreating SSH2 ED25519 key; this may take some time ...\n256 SHA256:NR2l3JkHZ5Ex0giKSdCMoXG/zngRJXUVwIyx8H55YUk root@rdf-dev (ED25519)\ninvoke-rc.d: could not determine current runlevel\ninvoke-rc.d: policy-rc.d denied execution of start.\n\nCurrent default time zone: 'Etc/UTC'\nLocal time is now: Thu Feb 1 14:27:43 UTC 2018.\nUniversal Time is now: Thu Feb 1 14:27:43 UTC 2018.\n\n\n##\n# The default user is 'ubuntu' with password 'ubuntu'!\n# Use the 'sudo' command to run tasks as root in the container.\n##\n\nThe configuration file contains legacy configuration keys.\nPlease update your configuration file!\nThe update script lxc-update-config -c <path-to-config> can be used for this.\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo lxc-update-config -c /var/lib/lxc/remoteJupyter/config",
"execution_count": 8,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo lxc-start -n remoteJupyter",
"execution_count": 9,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo lxc-ls --fancy",
"execution_count": 10,
"outputs": [
{
"text": "NAME STATE AUTOSTART GROUPS IPV4 IPV6 \nremoteJupyter RUNNING 0 - 10.0.3.174 - \n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ssh-keyscan 10.0.3.174 >> ~/.ssh/known_hosts",
"execution_count": 17,
"outputs": [
{
"text": "# 10.0.3.174:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4\n# 10.0.3.174:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4\n# 10.0.3.174:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sshpass -p ubuntu ssh-copy-id ubuntu@10.0.3.174",
"execution_count": 18,
"outputs": [
{
"text": "/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: \"/home/vagrant/.ssh/id_rsa.pub\"\n/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys\n\nNumber of key(s) added: 1\n\nNow try logging into the machine, with: \"ssh 'ubuntu@10.0.3.174'\"\nand check to make sure that only the key(s) you wanted were added.\n\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ssh ubuntu@10.0.3.174 ls -lachi",
"execution_count": 20,
"outputs": [
{
"text": "insgesamt 28K\n5901464 drwxr-xr-x 4 ubuntu ubuntu 4,0K Feb 1 14:34 .\n5900352 drwxr-xr-x 3 root root 4,0K Feb 1 14:27 ..\n5901465 -rw-r--r-- 1 ubuntu ubuntu 220 Feb 1 14:27 .bash_logout\n5901467 -rw-r--r-- 1 ubuntu ubuntu 3,7K Feb 1 14:27 .bashrc\n5901459 drwx------ 2 ubuntu ubuntu 4,0K Feb 1 14:34 .cache\n5901466 -rw-r--r-- 1 ubuntu ubuntu 655 Feb 1 14:27 .profile\n5901462 drwx------ 2 ubuntu ubuntu 4,0K Feb 1 14:34 .ssh\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ssh ubuntu@10.0.3.174 python --version",
"execution_count": 29,
"outputs": [
{
"text": "Python 2.7.12\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## RK einrichten\n\nTemplate erzeugen und anpassen."
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo rk install-template",
"execution_count": 22,
"outputs": [
{
"text": "installed template of remote kernel\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "jupyter-kernelspec list",
"execution_count": 23,
"outputs": [
{
"text": "Available kernels:\n ruby /home/vagrant/.local/share/jupyter/kernels/ruby\n bash /usr/local/share/jupyter/kernels/bash\n javascript /usr/local/share/jupyter/kernels/javascript\n python3 /usr/local/share/jupyter/kernels/python3\n template /usr/local/share/jupyter/kernels/template\n c /usr/share/jupyter/kernels/c\n",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /usr/local/share/jupyter/kernels/template/kernel.json",
"execution_count": 24,
"outputs": [
{
"text": "{\n \"argv\": [\n \"rkscript\",\n \"python\",\n \"{connection_file}\",\n \"remote_username@remote_host\"\n ],\n \"display_name\": \"Template\",\n \"language\": \"python\"\n}",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo sed -i s/remote_username@remote_host/ubuntu@10.0.3.174/g /usr/local/share/jupyter/kernels/template/kernel.json",
"execution_count": 26,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /usr/local/share/jupyter/kernels/template/kernel.json",
"execution_count": 27,
"outputs": [
{
"text": "{\n \"argv\": [\n \"rkscript\",\n \"python\",\n \"{connection_file}\",\n \"ubuntu@10.0.3.174\"\n ],\n \"display_name\": \"Template\",\n \"language\": \"python\"\n}",
"name": "stdout",
"output_type": "stream"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "markdown",
"source": "Leider läuft das nicht.\n\nEvtl. muss der pyhton kernel auf die Maschine eingerichtet werden."
}
],
"metadata": {
"language_info": {
"codemirror_mode": "shell",
"name": "bash",
"mimetype": "text/x-sh",
"file_extension": ".sh"
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": true,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"kernelspec": {
"name": "bash",
"display_name": "Bash",
"language": "bash"
},
"gist": {
"id": "",
"data": {
"description": "rdf/ais/remote jupyter/RK Test remote jupyter.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment