- PublicServerAutomator Github
- Changelog
- Author: Patrick Hastings
- Author Site:: https://gnubyte.com
- Pypi repository
This is a package intended to offer a much simpler, no hickups, no learning curve package + software alternative to Ansible/chef/puppet
Install via pip
pip install publicServerAutomator
Below is a brief tutorial of how to use this framework.
Here is how you authenticate SSH commands with private key authentication using PublicServerAutomator.
from publicServerAutomator import Server
dockerInstructions = [
"apt-get update -y",
"apt-get install apt-transport-https -y",
"apt-get install software-properties-common -y",
"apt-get install curl -y",
"apt-get install gnupg2 -y",
"apt-get install git -y",
"apt-get install acl -y",
"apt-get install fail2ban -y"
'''add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"''',
"apt-get update -y",
"apt-get install docker-ce -y",
"docker run hello-world"
]
newDocker = Server(inputKeyPath="publickey.pem", inputKeyPassword='PASS', inputServerIP="0.0.0.0" )
newDocker.set_commands(commandList=dockerInstructions)
newDocker.connect()
output = newDocker.run_commands()
print(output)
This is an example of running multiple commands on a host, without using a private key to authenticate.
Notice that the Username and password are specified using inputUserName
and inputPassword
.
from publicServerAutomator import Server
dockerInstructions = [
"apt-get update -y",
"apt-get install apt-transport-https -y",
"apt-get install software-properties-common -y",
"apt-get install curl -y",
"apt-get install gnupg2 -y",
"apt-get install git -y",
"apt-get install acl -y",
"apt-get install fail2ban -y"
'''add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"''',
"apt-get update -y",
"apt-get install docker-ce -y",
"docker run hello-world"
]
newDocker = Server(inputServerIP='8.8.8.8',inputUserName='root', inputPassword='123lookatme', inputKeyPath='')
newDocker.set_commands(commandList=dockerInstructions)
newDocker.connect()
output = newDocker.run_commands()
How to transfer files with SFTP w & w/o private key authentication
Here is how you transfer a file with a private key authentication
from publicServerAutomator import Server
someServer = Server(inputKeyPath="publickey.pem", inputKeyPassword='PASS', inputServerIP="0.0.0.0" )
someServer.connect()
someServer.transfer_file(full_path_local_file='/home/someGuy/mybigFile.gzip', full_path_target_path='/opt/someSoftware/mybigFile.gzip')
Here is how you transfer a file without a private key
from publicServerAutomator import Server
someServer = Server(inputServerIP='8.8.8.8',inputUserName='root', inputPassword='123lookatme', inputKeyPath='')
someServer.connect()
someServer.transfer_file(full_path_local_file='/home/someGuy/mybigFile.gzip', full_path_target_path='/opt/someSoftware/mybigFile.gzip')