SSH password log-in and command automator
Project description
ocsh - SSH password log-in and command automator
ocsh automates SSH password login and command execution through annotations on ssh_config(5) Hosts:
- password authentication, reading password from pass[1]:
- config:
# ocsh pass <pass-name> - command:
$ ocsh host
- config:
- post-login command execution:
- config:
# ocsh post <action> "<cmd>" - command:
$ ocsh host[action]
- config:
- post-login command execution, reading additional password from pass[1]:
- config:
# ocsh postpass <action> "<cmd>" <pass-name> - command:
$ ocsh host[action]
- config:
- use different ssh command or prefix by other command:
- config:
# ocsh cmd "<ssh-command>" - config:
# ocsh pre "<pre-command>" - command:
$ ocsh host
- config:
[1] https://www.passwordstore.org/
Compatibility with OpenSSH is kept as much as possible:
- support usual SSH aliases, keys and command-line options
- compatible with rsync, scp and other tools using SSH for transport, see example commands
- autocompletion can be set-up with --ocsh-install-autocompletion
Usage
usage: ocsh.py [-h] [--ocsh-verbose] [--ocsh-pretend] [--ocsh-examples]
[--ocsh-install-autocompletion]
[destination] ...
ocsh - SSH password log-in and command automator
positional arguments:
destination host[action]
args any OpenSSH options or remote command
options:
-h, --help show this help message and exit
--ocsh-verbose enable debug messages
--ocsh-pretend do not actually perform the connection
--ocsh-examples show example ocsh configuration and commands
--ocsh-install-autocompletion
install bash autocompletion for the current user
Installation
pip install ocsh
Examples of usage
# connect to SSH alias 'host1' with automated password login
# ssh_config(5)
Host host1
Hostname 10.0.0.1
User minou
# ocsh pass pass-location # location in password-store
# command
ocsh host1
# equivalent ssh command
sshpass -p "$(pass pass-location)" ssh host1
# connect to SSH alias 'host2' with automated password login, going through the above 'host1', and become root
# ssh_config(5)
Host host2
Host 10.9.0.1
User root
# ocsh pass pass-location2 # location in password-store
# ocsh postpass su "su -l" pass-location3
# ocsh post nsep "ip netns exec nsep" # post-login command to enter a network namespace
# command
ocsh host2[root]
# equivalent ssh command
sshpass -p "$(pass pass-location2)" ssh -oProxyCommand="sshpass -p "$(pass pass-location1)" ssh host1" host2 su -l
<now enter root password (from pass-location3) manually>
# run ssh connection from a different namespace
# ssh_config(5)
Host host1
Hostname 10.0.0.1
User minou
# ocsh pre "ip netns exec toto"
# command
ocsh host1
# equivalent command
ip netns exec ssh host1
# run rsync through ocsh from host1 with automated password login
rsync -e "ocsh" -avP host1:/etc/hosts /tmp/
# run scp through ocsh from host1 with automated password login
scp -S "ocsh" host1:/etc/hosts /tmp/
See also
- netmiko - python library to SSH to various network devices https://github.com/ktbyers/netmiko
- sshpass - automate SSH password-based log-in https://github.com/kevinburke/sshpass
- passh - sshpass alternative to automate SSH password-based log-in https://github.com/clarkwang/passh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ocsh-20230907.tar.gz
(6.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocsh-20230907.tar.gz.
File metadata
- Download URL: ocsh-20230907.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
519e178db465f7f22f11ceae812e3222e610f71f6dadd60f29951e28fcaa8e1f
|
|
| MD5 |
0c2dc4be0a1c314545a20d8a49263fcb
|
|
| BLAKE2b-256 |
7545cd61715a70e5974e3427ef84b3cddb8349d516db4beb02fa728bffb6e078
|
File details
Details for the file ocsh-20230907-py3-none-any.whl.
File metadata
- Download URL: ocsh-20230907-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9babb1f19c67c3b74014c7c6b72ccc4caf2505a932c73fac4ae7771ffffbe3b
|
|
| MD5 |
78b771a82d3a1f0caaecc36dc229c1c8
|
|
| BLAKE2b-256 |
f134b4a8522af0839e6a2cf962c8bc47e97afe95b4d445f1b80726b36083b945
|