ssh2container

package module
v0.0.0-...-6763dd5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 9 Imported by: 2

README

Latest Release Build Status

alt text

ssh2container

ssh2container is a ssh server which connects you directly to your docker container via ssh.

  • Supports TTY
  • Supports drush / rsync / scp
  • Supports sftp (for phpStorm)

Sample:

Connect to the cli container of project

    ssh project@192.168.64.100 -p 2222

Connect to the mysql container of project

    ssh project---mysql@192.168.64.100 -p 2222

For phpStorm

E.g. To connect phpStorm via ssh.

Startup:

docker run \
-d \
-e "HOST_UID=$(id -u)" \
-e "HOST_GID=$(cut -d: -f3 < <(getent group docker))" \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
--name andock-ssh2container \
--mount type=bind,src=${HOME}/.ssh/authorized_keys,dst=/home/docker/.ssh/authorized_keys \
-p 192.168.64.100:2222:2222 andockio/ssh2container --auth-type noauth
Add remote debugger

alt text

Add phpcs

alt text

Debug mode:
docker run \
-e "HOST_UID=$(id -u)" \
-e "HOST_GID=$(cut -d: -f3 < <(getent group docker))" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
--name andock-ssh2container \
-p 192.168.64.100:2222:2222 andockio/ssh2container --auth-type noauth --verbose

For sandbox servers:

E.g. to run drush sql-sync.

Startup:

docker run \
-d \
-e "HOST_UID=$(id -u)" \
-e "HOST_GID=$(cut -d: -f3 < <(getent group docker))" \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v ${HOME}/.ssh/authorized_keys:/home/docker/.ssh/authorized_keys:rw \
--name andock-ssh2container \
-p 0.0.0.0:2222:2222 andockio/ssh2container 

Login:

    ssh project@192.168.64.100 -p 2222

alt text

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoAuth

func NoAuth() ssh.Option

NoAuth for local development and testing

func PublicKeyAuth

func PublicKeyAuth(authorizedKeysFile string) ssh.Option

PublicKeyAuth perform public key authentification

func SSHHandler

func SSHHandler(sshHandler dockerClientInterface, config Config)

SSHHandler handles the ssh connection

Types

type Config

type Config struct {
	WelcomeMessage string
	DockerUser     string
	Cache          *cache.Cache
}

Config for ssh options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL