pub_keys v0.0.1 PubKeys
This mix project uses an Elixir script to manage public keys from a git server. It can add and remove public keys from all targetted servers.
pub_keys --help
to get helppub_keys --add "key here"
to add key to all serverspub_keys --remove "key here"
to remove key from all serverspub_keys --deploy-all
to push out auth_keys files to all servers (if you want to add a key to files manually, for example)
Summary
Functions
Prepend a key into the authorized_keys file if the key doesn’t exist inside the file yet
Given a list of ssh_keys files and the directory path of the files, this method will run scp_to_server
to copy the ssh key file to each remote server as per the ip address in the file name, and overwrite the remote authorized keys file
Prepends a key inside the specified authorized_keys file
Given an input of remote server’s IP address, and the directory path to ssh key files, returns a tuple containing the ip address and a list of the ssh_keys
Examples
iex> path = PubKeys.Helper.files_path(:test)
iex> PubKeys.read_keys("192.168.0.10", path)
{"192.168.0.10", ["ssh-rsa ABCD123abcd test1@work", "ssh-rsa XYZ987abcd test2@work"]}
Remove a key inside the specified authorized_keys file
Remove a key in the authorized_keys file if it does not exist inside the file
Given a file with IP Address as the name and the remote path where the authorized ssh keys are stored in the remote server. This method will run scp
system command from the specified file to the path in the remote server where the IP Address file name indicates
Functions
Prepend a key into the authorized_keys file if the key doesn’t exist inside the file yet
Given a list of ssh_keys files and the directory path of the files, this method will run scp_to_server
to copy the ssh key file to each remote server as per the ip address in the file name, and overwrite the remote authorized keys file.
Given an input of remote server’s IP address, and the directory path to ssh key files, returns a tuple containing the ip address and a list of the ssh_keys
Examples
iex> path = PubKeys.Helper.files_path(:test)
iex> PubKeys.read_keys("192.168.0.10", path)
{"192.168.0.10", ["ssh-rsa ABCD123abcd test1@work", "ssh-rsa XYZ987abcd test2@work"]}
Remove a key in the authorized_keys file if it does not exist inside the file