Web based SSH access to your Raspberry Pi
by Amit
See here for Fedora instructions.
Using wssh, you can setup a web based SSH access mechanism to your Raspberry Pi. This looks more attractive when you expose your Pi using a public IP address/hostname using a service like Pagekite. Let us see how (I am assuming your Raspberry Pi is running raspbian).
Installing wssh
wssh has a bunch of dependencies which you can install with a mix of apt-get and easy_install. Note that we will be using the in built wssh server, ‘wsshd’ which uses Flask for the Web application, hence we install Flask as well.
Install the dependencies:
pi@raspberrypi ~ $ sudo apt-get install python-dev libevent-dev pi@raspberrypi ~ $ sudo easy_install gevent flask paramiko gevent-websocket wssh
It will take some time for these to install and once they are completed, you should be able to start the wssh server. If you get a message like that, your server is up and running and you can visit the URL in your browser.
pi@raspberrypi ~ $ wsshd wsshd/0.1.0 running on 0.0.0.0:5000
You will be greeted with a login screen such as the one below:
Note that this server is running on your Raspberry Pi, and hence localhost means the Pi itself. (You can ofcourse use any other computer’s hostname or IP address on your network). If you have been logged in succesfully, you should see the shell:
And then you can do all you wish to right there in your browser.
Public facing hostname
Once you make the server reachable at a public facing hostname, things get really interesting since you can now access your Pi from anywhere in the world, literally. A service like Pagekite.net can help achieve that. Once you have installed Pagekite and signed up using your email address, you can start ‘wsshd’ as a background process and tell Pagekite to make the 5000 port available as your chosen kite name:
$ wsshd & $ pagekite.py 5000 yourpi.pagekite.me
And you should have your SSH login screen at your chosen kitename: http://yourpi.pagekite.me in this case. And ofcourse, you can use the instructions here to set this up for any of your other computers running Linux.
U forgot python-setuptools as dependencie.
Thanks. I did miss it. Will update it in the post.
Hey, i’ve followed this idea, I was wondering if this is possible with localtunnel as I don’t want to pay monthly for PageKite. I get the WSSH page up fine when it’s all up and running from another PC away from the local host, but it says Connectiong …….Connection rejected by peer. I know for certain it’s not a password issue as I can log in with the same creds on the local machine. Do you have any ideas? Thanks.
Hi!
I tried following the setup as explained in the post. I do see the message in the terminal “wsshd/0.1.0 running on 0.0.0.0:5000” but do not see any login screen. Could you advise me on the possible cause for error. Thanks!
Ah! Sorry about the silly question, I didn’t notice the part that said “visit the url in a browser”. Thanks so much for the post :)
Many thanks for the post, it was really instructional. Could you please add the remaining simple steps to make it run as a service ?
You totally made my day !
What Linux distribution are you on? Raspbian or Fedora?
I use the Wheezy distro for Raspberry Pi. I created manually a service file in /etc/init.d/ like that:
#! /bin/sh
# /etc/init.d/wsshd
# Carry out specific functions when asked to by the system
case “$1” in
start)
sudo wsshd&
;;
stop)
sudo kill $(ps aux | grep ‘wsshd’ | awk ‘{print $2}’)
;;
*)
echo “Usage: /etc/init.d/blah {start|stop}”
exit 1
;;
esac
exit 0
But this does not do the trick. I can start manually the service with “service wsshd start” but when I restart the raspberry, the service is not started.
Thanks for help.
Thomas
Hi Thomas, I haven’t tested this, but may be you are missing the update-rc.d step? (Please see: http://www.debian-administration.org/articles/28). I hope that solves your problem?
Hi Amit and thanks for the prompt answer, I would have it googled later on :)
The command does work with some warnings:
pi@waitforit ~ $ sudo update-rc.d wsshd defaults
update-rc.d: using dependency based boot sequencing
insserv: warning: script ‘wsshd’ missing LSB tags and overrides
insserv: warning: script ‘pushover’ missing LSB tags and overrides
Thank you very much ! Your help and posts are much appreciated !
It did actually ! Many thanks !
Totally forgot that step. It works just fine.
Just few annoying limitations from wsshd:
– no copy/paste
– no mouse selection
– fixed sized window
However, many thanks to the evil developers behind that. I can access my server from any device from anywhere. So convenient !
Thanks for the great post.
I propose you add the following instructions to run it as a service. It will help a lot of people.
Cheers from France
Hi, thank you for the post, it has been really useful!
Do you know how I could acces the raspberry pi with a dynamic dns (I’m using no-ip.com) as a hostname?
I get no terminal window in the browser after attempting to sign in, any ideas what is wrong?
Weird how it happened in Google Chrome (You’re using Google Chrome, right?), but not in Firefox (Which I personally don’t like.). It should work in Firefox.
Any idea how to get it working in Google Chrome?
It works very nice in Firefox. Thank you for the nice program!
Sorry, forget my question about Chrome. Chrome cannot load github content (issue #7). Applying the patch and now it works!
Thank you again!
[…] via Pocket http://echorand.me/2012/10/13/web-based-ssh-access-to-your-raspberry-pi/ […]
When I try to start wsshd, the pi returns an Import Error:
ImportError: cannot import name WebSocketHandler
Any insight on to why this might be happening?
Looks like there is an open issue regarding this: https://github.com/aluzzardi/wssh/pull/9
You can either comment there to ask the author to commit the fix soon, or do it yourself in a local git clone. If you want help with the latter, let me know.
Everything is very open with a very clear clarification of the
challenges. It was really informative. Your website is useful.
Thank you for sharing!