How to connect to a remote kernel in a ipynb file? [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'd like to know how to use a remote AWS instance as the backend for my ipython notebook that I have running locally. I typically use nteract as the frontend for my jupyter notebook.
Motivation: is that my macbook doesn't have an Nvidia GPU, so I'd like the computations done on my P2 instance remotely, but with the notebook running locally.
This is my first question, so please be gentle :)

Typically you ssh to an AWS instance using something like
$ ssh -i key.pem username#ec2-198-51-100-1.compute-1.amazonaws.com
You can local forward to a port, say 8888, with
$ ssh -i key.pem -L 127.0.0.1:8888:127.0.0.1:8888 username#ec2-198-51-100-1.compute-1.amazonaws.com
This will forward anything running on localhost at port 8888 on your AWS instance, to localhost 8888 on your MacBook.
Then on your AWS instance, launch an ipython notebook
$ jupyter notebook --no-browser --port 8888
and then on your MacBook, open a browser and navigate to localhost:8888 and you'll be using the notebook from your AWS instance (which has GPU support).
Hope this helps.

Related

How to connect to a remote Jupyter notebook server? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
I want to run a jupyter notebook server in a machine to which I have ssh access and that I am already able to run notebooks locally.
How can I setup the jupyter notebook so it can be accessed remotely?
If you have ssh access to the machine that will run the server, follow the next steps:
1) In the machine that you will run the server, execute:
jupyter notebook # To start the server with the default port forwarding (8888)
2) Take note of the notebook address: that will be shown to you in the terminal: http://localhost:8888/?token=<A_LONG_STRING_OF_NUMBERS_AND_LETTERS>
3) In the client machine, with remote access to the server:
ssh -N -L localhost:8888:localhost:8888 <server_username>#<server_ip>
4) Now, open the browser to use the following address: http://localhost:8888/?token=<THE_TOKEN>
Additional info (found here): It is possible to change the port on which the server is setup
# In the server
jupyter notebook --no-browser --port=8889
# In the client
ssh -N -L localhost:8888:localhost:8889 <server_username>#<server_ip>

Gtk-WARNING **: cannot open display: :0.0 --- Ubuntu 14.04 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I have just installed OpenCV 3.2.0 on an amazon EC2 instance (ubuntu 14.04). When I try to run any of the sample programs I get the error Gtk-WARNING **: cannot open display: :0.0
Answers to similar questions online didn't work for me. I've tried
export DISPLAY=:0.0
export DISPLAY=:0
and I tried xhost +localhost and received xhost: unable to open display ":0.0"
This post describes the exact same problems as me, but I'm not using Vagrant, so there is no "Vagrantfile" and I don't know what the equivalent would be in an EC2 instance.
Gtk-WARNING **: cannot open display:
Does anyone have an idea of why this is happening?
I'm on Ubuntu 16.04 using ssh to Ubuntu 16.04.2 server. I can do the following:
xhost +
ssh -Y -i .ssh/my.pem ubuntu#ecxxxxxxx.eu-west-1.compute.amazonaws.com
sudo apt install x11-apps
xclock
This starts the xclock applet on my local display. Note the xhost + before I ssh and the -Y flag on the ssh command. I'm using xclock to test which I installed from x11-apps. You should be able to start OpenCV in a similar way.

Remote SSH server accessing local files [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Is it possible to access local files via remote SSH connection (local files of the connecting client of course, not other clients)?
To be specific, I'm wondering if the app I'm making (which is designed to be used over SSH, i.e. user connects to a remote SSH server and the script (written in Python) is automatically executed) can access local (client's) files. I want to implement an upload system, where user(s) (connected to SSH server, running the script) may be able to upload images, from their local computers, over to other hosting sites (not the SSH server itself, but other sites, like imgur or pomf (the API is irrelevant)). So the remote server would require access to local files to send the file to another remote hosting server and return the link.
You're asking if you can write a program on the server which can access files from the client when someone runs this program through SSH from the client?
If the only program running on the client is SSH, then no. If it was possible, that would be a security bug in SSH.

Script to Shutdown Ubuntu [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to write a script which can Shutdown remote Ubuntu system. Actually i want my VM to shutdown safely when i shutdown my main machine on which my VM is installed .
Is there is any of doing this with the help of Sh scripts or script written in any language like Python.
You can run the following command from a remote Linux machine (VM Host):
ssh root#<vm-client-ip> "shutdown -h now"
You will have to input your root password for the remote machine. You can prevent this by adding ssh certificates (good if you are writing a script):
SSH login without password
If you make a script out of this, don't forget to add a delay after the shutdown (e.g. sleep 10) so that the VM will have time to die peacefully.
A complete bash script (untested):
#!/bin/bash
ssh root#<vm-client-ip> "shutdown -h now"
sleep 10
You can use the hypervisor, i.e. the qm script in case of qemu/KVM
qm shutdown 300 && qm wait 300
It shuts down the VM with ID 300, and wait for the VM to stop. See the qm manual for more options.
There are very many ways to turn off a Linux system. The preferred way is to call your window manager's shutdown sequence. If you're using gdm (which you probably are if you're using Ubuntu you want to use:
gnome-session-quit --power-off
If you're using kdm the command is:
kdmctl shutdown
Other ways of shutting down the computer (which may or may not be mostly or completely equivalent, but all require superuser rights) include:
/sbin/init 0
/sbin/halt
/sbin/shutdown -h now
/sbin/poweroff
etc, etc.
The actual command with shuts a system down is shutdown, specifically
$ shutdown -h now
shuts it down now. This needs to be run with superuser privileges on the machine you want to stop.
You can call poweroff from a script, as long as it's running with superuser privileges.
Depending on which virtualization product you are using (e.g. KVM, VirtualBox, VMWare, etc.), there should be a suitable interface you can use.
I suggest you search Google for the name of your chosen virtualisation software + "API". All of the above examples have relevant results that can be called from e.g. Python.
For VirtualBox, check out this link: https://blogs.oracle.com/nike/entry/python_api_to_the_virtualbox
That should give you a SOAP interface which should allow you remote control via e.g. cURL.
Alternatively for the remote aspect, you could setup private key authentication on the server and save your key's passphrase locally (with e.g. Seahorse), which would allow you secure ssh access without the need to enter your password each time.

How to FTP into a virtual machine? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've recently started learning Django and have set up a virtual machine running a Django server on VirtualEnv. I can use the runserver command to run the basic Django installation server and view it on another computer with the local IP address.
However, I can't figure out how to connect to my virtual machine with my FTP client so that I can edit files on my host machine (Windows). I've tried using the IP address of the virtual machine with an FTP client but it says "Connection refused by server".
Any help would be appreciated, thanks!
The reason that the the client reported back "Connection refused by server" is that the server returned a TCP packet with the reset bit set, in response to an application trying to connect to a port that is not being listened on by an application, or by a firewall.
I think that the FTP service is not running, or running on an alternate port. Take a look at the output from netstat -nltp (on Linux) or netstat -ntlb (on windows). You should see a program that is waiting to hear request on TCP port 21. If you don't see the program listed at all or not on the expected port that your client is going to try and connect to, then modify the FTP servers configuration file.

Categories