Skip to content

Instantly share code, notes, and snippets.

@kristianlm
Created June 22, 2018 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristianlm/0678acbbd04956ab8e8d558251b3e4f7 to your computer and use it in GitHub Desktop.
Save kristianlm/0678acbbd04956ab8e8d558251b3e4f7 to your computer and use it in GitHub Desktop.
(use minissh nrepl)
;; the default /dev/random causes hangs
(use tweetnacl) (current-entropy-port (open-input-file "/dev/urandom"))
;; the secret key would normally be kept safe
(define host-pk
"AAAAC3NzaC1lZDI1NTE5AAAAIIfd+rbtTF2hJJbnnbQxtp2UVrUWkQtnsT8CL9iLpZBZ")
(define host-sk
#${ba72291c15494ee02003b3c0bb0f8507a6a803850aa811d015b141a193e2447d
87ddfab6ed4c5da12496e79db431b69d9456b516910b67b13f022fd88ba59059})
(print "test with: ssh localhost -p 22022 repl # any user, any password")
(ssh-server-start
host-pk host-sk
(lambda (ssh)
(userauth-accept ssh password: (lambda _ #t) publickey: (lambda _ #t))
(tcp-read-timeout #f)
(port-for-each
(lambda (ch)
(thread-start!
(lambda ()
(with-channel-ports*
ch (lambda ()
(print "this is a CHICKEN SSH server, demoing minissh")
(cond ((channel-command ch) =>
(lambda (cmd) (print "-=- you ran command '" cmd "' -=-" )))
(else (print "-=- you ran ssh interactively -+-") )))))))
(lambda () (channel-accept ssh)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment