add docker image to run it in windows

This commit is contained in:
Federico Luzzi 2023-12-06 17:46:10 -03:00
parent 3e32aa958c
commit 3d5db06343
7 changed files with 52 additions and 3 deletions

View File

@ -4,12 +4,19 @@
[![](https://img.shields.io/pypi/l/connpy.svg?style=flat-square)](https://github.com/fluzzi/connpy/blob/main/LICENSE)
[![](https://img.shields.io/pypi/dm/connpy.svg?style=flat-square)](https://pypi.org/pypi/connpy/)
Connpy is a ssh and telnet connection manager and automation module
Connpy is a ssh and telnet connection manager and automation module for Linux, Mac and Docker
## Installation
pip install connpy
### Run it in Windows using docker
```
git clone https://github.com/fluzzi/connpy
docker compose -f path/to/folder/docker-compose.yml build
docker compose -f path/to/folder/docker-compose.yml run -it connpy-app
```
## Automation module usage
### Standalone module
```

View File

@ -482,7 +482,7 @@ class node:
cmd = cmd + " {}".format(self.host)
else:
cmd = cmd + " {}".format("@".join([self.user,self.host]))
expects = ['yes/no', 'refused', 'supported', 'Invalid|[u|U]sage: (ssh|sftp)', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', '[p|P]assword:|[u|U]sername:', r'>$|#$|\$$|>.$|#.$|\$.$', 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching", "bad permissions"]
expects = ['yes/no', 'refused', 'supported', 'Invalid|[u|U]sage: (ssh|sftp)', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', '[p|P]assword:|[u|U]sername:', r'>$|#$|\$$|>.$|#.$|\$.$', 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching", "[b|B]ad (owner|permissions)"]
elif self.protocol == "telnet":
cmd = "telnet " + self.host
if self.port != '':
@ -495,7 +495,7 @@ class node:
passwords = self._passtx(self.password)
else:
passwords = []
expects = ['[u|U]sername:', 'refused', 'supported', 'invalid option', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', '[p|P]assword:', r'>$|#$|\$$|>.$|#.$|\$.$', 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching", "bad permissions"]
expects = ['[u|U]sername:', 'refused', 'supported', 'invalid option', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', '[p|P]assword:', r'>$|#$|\$$|>.$|#.$|\$.$', 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching", "[b|B]ad (owner|permissions)"]
else:
raise ValueError("Invalid protocol: " + self.protocol)
attempts = 1

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
version: "3.8"
services:
connpy-app:
build: .
image: connpy-app
volumes:
- ./docker/connpy/:/app
- ./docker/logs/:/logs
- ./docker/ssh/:/root/.ssh/

4
docker/connpy/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
docker/logs/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
docker/ssh/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

21
dockerfile Normal file
View File

@ -0,0 +1,21 @@
# Use the official python image
FROM python:3.11-alpine as connpy-app
# Set the entrypoint
# Set the working directory
WORKDIR /app
# Install any additional dependencies
RUN apk update && apk add --no-cache openssh fzf fzf-tmux ncurses bash
RUN pip3 install connpy
RUN connpy config --configfolder /app
#AUTH
RUN ssh-keygen -A
RUN mkdir /root/.ssh && \
chmod 700 /root/.ssh
#Set the entrypoint
ENTRYPOINT ["connpy"]