SuperShinyEyes / automation-scripts

Scripts for Automation
GNU General Public License v3.0
3 stars 0 forks source link

Doesn't work if public key is not set. #1

Open SuperShinyEyes opened 6 years ago

SuperShinyEyes commented 6 years ago

I wrote a pretty detailed explanation of the problem at the code: https://github.com/YoungxHelsinki/automated-scripts/blob/e16a652018ce6f66045ba69f0b314c334820488d/Aalto_computer_status_checker/paniikki_jupyter_launcher.py#L12-L49

Problem

The code works only when you have your RSA Key registered on the remote.

Goal:

Make code so works without RSA Key. Now I couldn't find a way to get stdout. Seems like I have to use a socket. For instance, the following gives some hint how I could use a socket:

argv = (["ssh", "parks1@kosh.org.aalto.fi", "ssh bit"])
(s1, s2) = socket.socketpair()
def setup():
    # runs in the child process
    s2.close()
s1a, s1b = os.dup(s1.fileno()), os.dup(s1.fileno())
s1.close()
p = subprocess.Popen(argv, stdin=s1a, stdout=s1b, preexec_fn=setup,
                      close_fds=True)#, stderr=stderr)
# os.close(s1a)
# os.close(s1b)
(serverproc, serversock) = (p, s2)
expected = b'SSHUTTLE0001'
initstring = serversock.recv(len(expected))
initstring

The above won't work if you don't have a public key set up. You get:

ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or directory
Permission denied, please try again.

Check sshuttle: https://github.com/apenwarr/sshuttle/blob/083293ea0dc2ebc77f282c2803720a2bb5f21a80/sshuttle/ssh.py#L124 https://github.com/apenwarr/sshuttle/blob/083293ea0dc2ebc77f282c2803720a2bb5f21a80/sshuttle/client.py#L418

Must find a way to pass stdout like a native view. This might also enable jupyter notebook launch within Python code.

SuperShinyEyes commented 6 years ago

Made a youtube video for explanation: https://www.youtube.com/watch?v=EP8C4NXY1bo&feature=youtu.be