/faassh

simple go SSH server with reverse tunneling designed for running in cloud functions like AWS lambda

Primary LanguageGo

faassh

simple go SSH server designed for running in cloud functions

image

This is just for fun. It's a simple SSH server and tunnel-er that allows you to SSH into a running lambda function—until it times out.

Developed for my dotScale 2017 talk, "Searching for the Server in Serverless". Slides here.

building

This project uses the Serverless Application Model for packaging and deploying.

   $ sam build
   $ sam package --s3-bucket <yourbucket> > packaged.yaml
   $ sam deploy --template-file packaged.yaml --stack-name <yourstack> --capabilities CAPABILITY_IAM

usage

   faassh -i ./path_to_private_rsa_host_key -p port_number

example

See the example node.js lambda function in the lambda/ directory.

  • Generate RSA keys for the Lambda function and bundle inside the lambda directory (ssh-keygen -t rsa -f ./id_rsa)
  • Set the envionment variables to point to your SSH jump host with the correct username.

If you'd like to test it on your local laptop that's behind (hopefully) a NAT/firewall, I like the TCP forwarding available on ngrok. You can create a tunnel to your local SSH server for the other end of the tunnel endpoint, you just run: ngrok tcp 22.

other interesting/related projects

  • lambdash - another approach for running commands in Lambda
  • awslambdaproxy - An AWS Lambda powered HTTP/SOCKS web proxy

todo

  • better authentication support
  • other cloud providers
  • connection cleanup
  • terraform/cloudformation helper
  • multiple connections
  • tests and docs :)