From 880da274c9c941a629dd52e2c775640ce8c3dd07 Mon Sep 17 00:00:00 2001 From: Federico Luzzi Date: Wed, 6 Dec 2023 17:46:10 -0300 Subject: [PATCH 1/2] add docker image to run it in windows --- README.md | 9 ++++++++- connpy/core.py | 4 ++-- docker-compose.yml | 9 +++++++++ docker/connpy/.gitignore | 4 ++++ docker/logs/.gitignore | 4 ++++ docker/ssh/.gitignore | 4 ++++ dockerfile | 21 +++++++++++++++++++++ 7 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker/connpy/.gitignore create mode 100644 docker/logs/.gitignore create mode 100644 docker/ssh/.gitignore create mode 100644 dockerfile diff --git a/README.md b/README.md index 1f5678b..c580d15 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/connpy/core.py b/connpy/core.py index 924fabd..62b77e6 100755 --- a/connpy/core.py +++ b/connpy/core.py @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..88a622b --- /dev/null +++ b/docker-compose.yml @@ -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/ diff --git a/docker/connpy/.gitignore b/docker/connpy/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/docker/connpy/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/docker/logs/.gitignore b/docker/logs/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/docker/logs/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/docker/ssh/.gitignore b/docker/ssh/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/docker/ssh/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..a6baeae --- /dev/null +++ b/dockerfile @@ -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"] From b3c4186a6c7058b1b0663de0d4646c29df61e238 Mon Sep 17 00:00:00 2001 From: Federico Luzzi Date: Wed, 6 Dec 2023 17:46:39 -0300 Subject: [PATCH 2/2] change version and docs --- connpy/_version.py | 2 +- docs/connpy/index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/connpy/_version.py b/connpy/_version.py index 2691862..63c0699 100644 --- a/connpy/_version.py +++ b/connpy/_version.py @@ -1,2 +1,2 @@ -__version__ = "3.7.0" +__version__ = "3.7.1" diff --git a/docs/connpy/index.html b/docs/connpy/index.html index 6f9a042..44bf7fd 100644 --- a/docs/connpy/index.html +++ b/docs/connpy/index.html @@ -3876,7 +3876,7 @@ tasks: 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 != '': @@ -3889,7 +3889,7 @@ tasks: 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