I checked both repl from lein and clojure 1.8 socket repl, looks like none of them support username/password. if I open the repl to outside connection, how to make it safe? Or need to use ssh to login into the host and then from that host to connect to repl?
By default, the socket REPL binds to loopback, so it will only accept connections made from that machine. That seems to be the safest method by far. Then you can use whatever auth methods you like to get onto that machine. SSH, or my personal favourite mosh are both good options.
It is plausible that you could create some kind of authentication system by providing your own REPL function, and allowing only authenticated connections from all comers, but I think that is likely to be extremely unwise and unsafe.