Sign inSign up

samabsalom/ssh-with-2fa

By samabsalom

•Updated about 5 years ago

A docker image that by default runs ssh with 2fa with google authenticator

Image
0

1.1K

samabsalom/ssh-with-2fa repository overview

Docker image with SSH and google authenticator installed

Run the compose file below with your own ssh public key as an environment variable to allow access once running the container will make new id_rsa and id_rsa.pub files (to ssh out as i use this as a jump server) and add them to the volume listed below It will also make a new .google_authenticator file (there is also a txt file with a url to show the QR code for some apps to use. This does expose your key to the browser!)

I am absolutely not a security expert but i believe most of this file is standard practice. Please us at your own risk

To setup the mobile App: Install it (i use authy) -> Set up account -> Type the first line from the .google_authenticator file. -> Then ssh the container as root with your private key and provide the Google Authenticator code

version: "3"
services:
  2fa:
    container_name: 2fa
    environment:
      - PUBKEY=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC59d1Ymhfw54Cz2dmRb3mOLbMRaK6aWRJqoQc2bhupuHv+0yR+abxzUuFv1LhB+ziMjyMZVUEqB4x2du9wqoHoKzOwGjzVpHhAH+NVkqNJKDYbBa0F9sNuLeK6IFy5CVtj6jXxoOt1gOZBDu3URwEH0hI+Orv8k7ZhJ7mMxeKvLUR5n7jEot6fu3vsGX2TjKSrXCL3j6MKrr1D6vQXtdjHuo3IspAAi/n58av1q89g2lYXFYl+L9gjkCQSCbjX2TyInsiv+Ddjz4NVSPuP3+xZHuViV8bvqr8qVi3rykvlXJEtAa9Z+gSnJIoze/mRaaSr70iwWvVzP/a1gEt4WLVzz09AoucJ2nmuvDiI9XZ/79K2jHntZKvyUhKnw/dKfIRk57DQQe36EYVbCaRRSuUJzJEXjBJWEg3btQka57TskCm9y6yGV7lz/A26HRcMaph4rSvEp+TOnAhhTjFtZnX7J+0RO4nCAIHuZ+J7VPwH3i4SvQLUFq1MhFLxxNW1IpsSgu1yGPsIOCIWBfZajg/OI2wayth00cOqniwlnP5yBeC80WFan7FvUKzHUI4kJZOF5G0Fqvow/HynqajVDpQogj1xl0qdf09D9ujs8z4hz4Hlegy/j4p7VQPlUur/kOTWKwXjbvCEYTVhBkywVENcMKwoYvO+nmIkzPMUo6ztwQ== newmadeupkey
    volumes:
      - /your/own/dir/2fa:/root
    image: samabsalom/ssh-with-2fa:latest
    ports:
      - 33:22/tcp
    network_mode: bridge

In future i will add custom users and add env variables for the google authenticator command to customise yourself

Tag summary

Content type

Image

Digest

Size

69.3 MB

Last updated

about 5 years ago

docker pull samabsalom/ssh-with-2fa