new feature: ssh into projects

269 views
Skip to first unread message

William Stein

unread,
Jul 1, 2014, 8:18:56 PM7/1/14
to sage-cloud, Ondřej Čertík, Keith Clawson
Hi,

We've just finished a first usable version of an often-requested
feature. You can now...

** easily ssh into any project using a standard ssh client program **

Just refresh your browser (to get the update), then in project
settings under "Status" you'll find a section labeled "SSH into your
project", with the ssh command line that you can type (on any computer
anywhere) to ssh to your project.

For this to work, you *MUST* add an ssh public key to your project.
There is a link "add a public key to ~/.ssh/authorized_keys" right
there, so click on it, and paste an ssh public key into that file,
then save it. Now you can ssh to your project.

This is useful since you can use any terminal, setup git push/pull, do
ssh port forwarding (for developing servers), etc.

-- William

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
Screen Shot 2014-07-01 at 5.17.54 PM.png

Harald Schilly

unread,
Jul 2, 2014, 8:58:14 AM7/2/14
to sage-...@googlegroups.com, Ondřej Čertík, Keith Clawson
It also works for X forwarding, that's nice.

I.e. although painful slow, one can do

ssh -CX -p <port> <username>@<ip> ipython qtconsole

or

ssh -CX -p <port> <username>@<ip> octave --force-gui

The "-C" is for compression, which helps a little bit.

Harald

Harald Schilly

unread,
Jul 3, 2014, 9:43:34 AM7/3/14
to sage-...@googlegroups.com
... and another bonus trick: it also works for IPython kernels:

1. on SMC:
$ ipython kernel
Then you can connect to this compuational kernel from somewhere else.

2. Get the file with the authentication key:
$ open ~/.sage/ipython-1.2.1/profile_default/security/kernel-8784.json
where the 1.2.1 version number might change and the number at the end
definitely changes.

3. Once you have the file on your local machine:
$ ipython console --existing ./kernel-8784.json --ssh <username>@<ip>:<port>

Harald

Jorge A. Alfaro-Murillo

unread,
Jul 3, 2014, 10:10:12 AM7/3/14
to sage-...@googlegroups.com
Harald Schilly <harald....@gmail.com> writes:

> ... and another bonus trick: it also works for IPython kernels:

* For emacs fans:

You can ssh to your project (C-x C-f /ssh:user@host: <enter>), open a
.py file from your project and call python-shell-switch-to-shell (C-c
C-z) press <enter> and have the python shell running remotely on SMC
and displaying in your local emacs.

To use ipython instead:

#+BEGIN_SRC emacs-lisp
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args ""
python-shell-prompt-regexp "In \\[[0-9]+\\]: "
python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
python-shell-completion-setup-code
"from IPython.core.completerlib import module_completion"
python-shell-completion-module-string-code
"';'.join(module_completion('''%s'''))\n"
python-shell-completion-string-code
"';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
#+END_SRC


* For everybody (or I guess everybody with Linux):

For easier access for every project, include an entry in your
~/.ssh/config of the form:

#+BEGIN_EXAMPLE
Host smc-THEPROJECTNAME
HostName THENUMBERSWITHPOINTSAFTERTHE@
User THECHARACTERSBEFORETHE@
IdentityFile ~/.ssh/YOURKEYFORSMC
#+END_EXAMPLE

Now you can simply: ssh smc-THEPROJECTNAME

Harald Schilly

unread,
Jul 3, 2014, 10:29:17 AM7/3/14
to sage-...@googlegroups.com
yes, adding it to the ssh config file is also useful! In case the port
number changes (I don't know? but in one case there is a "-p 2222" in
the command-line for me), you also have to add such a line below
HostName:

Port <insert your 4 to 5 digit number>

William Stein

unread,
Jul 3, 2014, 3:15:51 PM7/3/14
to sage-cloud
On Thu, Jul 3, 2014 at 7:28 AM, Harald Schilly <harald....@gmail.com> wrote:
> yes, adding it to the ssh config file is also useful! In case the port
> number changes (I don't know? but in one case there is a "-p 2222" in
> the command-line for me),

Projects can move from one machine to another, in which case the ip
address and possibly the port could change.
This should rarely happen though.

Right now projects at UW have port 2222, and those at Google have port
22 (the default).

-- William

> you also have to add such a line below
> HostName:
>
> Port <insert your 4 to 5 digit number>
>
> On Thu, Jul 3, 2014 at 4:09 PM, Jorge A. Alfaro-Murillo
> <jorge.a...@gmail.com> wrote:
>> For easier access for every project, include an entry in your
>> ~/.ssh/config of the form:
>>
>> #+BEGIN_EXAMPLE
>> Host smc-THEPROJECTNAME
>> HostName THENUMBERSWITHPOINTSAFTERTHE@
>> User THECHARACTERSBEFORETHE@
>> IdentityFile ~/.ssh/YOURKEYFORSMC
>> #+END_EXAMPLE
>
> --
> You received this message because you are subscribed to the Google Groups "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/CAGG4CB4Nc6BeRn2ak4QanwwUJfV4s9SjdJut_ssa5HpzGdCtwg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Aron Ahmadia

unread,
Jul 3, 2014, 3:18:19 PM7/3/14
to sage-...@googlegroups.com, Ondřej Čertík, Keith Clawson, David Ketcheson
Wow, awesome!  Thanks so much for this William.

A


--
You received this message because you are subscribed to the Google Groups "sage-cloud" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+...@googlegroups.com.

Patrick Reynolds

unread,
Sep 25, 2014, 8:14:38 AM9/25/14
to sage-...@googlegroups.com, ondrej...@gmail.com, kcla...@uw.edu
I love this feature.  However, sometimes I'm able to ssh and sometimes I'm not.   When I *can* login, the prompt is "Enter passphrase for key: ...".   When I can't, I get a prompt for "(long-alpha-numeric-string)'s password:", for which my password doesn't work.  If I then access my project through my browser and try again, the correct ssh prompt appears and I can login.  But then, interestingly, if I logout of SMC in the browser, and logout of ssh, I *can* login through ssh again without recourse to the browser.  I can't figure out what's going on, but I'd love to be able to access smc without ever opening my browser. 

Thanks for all the hard work on this.

Harald Schilly

unread,
Sep 25, 2014, 8:27:15 AM9/25/14
to sage-...@googlegroups.com, Ondrej Certik, Keith Clawson
On Thu, Sep 25, 2014 at 2:14 PM, Patrick Reynolds <reyno...@gmail.com> wrote:
> I can't figure out what's going on, but I'd love to be able to access smc
> without ever opening my browser.

What you describe has a very easy explanation: Your project runs on
the server on demand. Even when you close your browser, it still
continues to do what it is doing (hub-server, a calculuation is
running, etc.) After a certain timeout -- or when the server has to
restart -- all your project's processes are terminated. You can see
the timeout in the project settings and william can turn that value
up, even to infinity ;-)

There is currently no mechanism to spin up a resting project while you
only log in. I think this could be a bit tricky, especially when it
takes more time to start the project than your ssh timeout is waiting.

-- harald

Patrick Reynolds

unread,
Sep 25, 2014, 10:06:49 AM9/25/14
to sage-...@googlegroups.com, ondrej...@gmail.com, kcla...@uw.edu
Ok, thanks very much.


On Tuesday, July 1, 2014 9:18:56 PM UTC-3, William Stein wrote:

William A Stein

unread,
Sep 25, 2014, 11:10:29 AM9/25/14
to sage-cloud, Ondrej Certik, Keith Clawson
On Thu, Sep 25, 2014 at 5:26 AM, Harald Schilly
<harald....@gmail.com> wrote:
> On Thu, Sep 25, 2014 at 2:14 PM, Patrick Reynolds <reyno...@gmail.com> wrote:
>> I can't figure out what's going on, but I'd love to be able to access smc
>> without ever opening my browser.
>
> What you describe has a very easy explanation: Your project runs on
> the server on demand. Even when you close your browser, it still
> continues to do what it is doing (hub-server, a calculuation is
> running, etc.) After a certain timeout -- or when the server has to
> restart -- all your project's processes are terminated. You can see

Yes. I have lately tried to not restart the servers too frequently;
many have 45 days uptime.

> the timeout in the project settings and william can turn that value
> up, even to infinity ;-)

Indeed -- send me the id of your project, and I can manually increase
the timeout from 3 hours to much longer. wst...@uw.edu.

> There is currently no mechanism to spin up a resting project while you
> only log in. I think this could be a bit tricky, especially when it
> takes more time to start the project than your ssh timeout is waiting.



>
> -- harald
>
> --
> You received this message because you are subscribed to the Google Groups "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/CAGG4CB4%3D%3Dxe0_BdUXXHJTXykQgaGQVWT_%3DxcoNF9M9v8RBxOyg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
wst...@uw.edu
Reply all
Reply to author
Forward
0 new messages