Skip to content

gcoop-libre/multi-ssh-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi SSH Config

overview

Generate ~/.ssh/config from multiple directories and files with one host config per file.

install

Clone the repository:

cd ~
git clone https://github.com/gcoop-libre/multi-ssh-config

Add to ~/.bashrc:

if [ -d "$HOME/multi-ssh-config" ]
then
    PATH="$HOME/multi-ssh-config:$PATH"
fi

sshconfig

After edit hosts and alias files in config directory you can run:

cd ~/multi-ssh-config
./sshconfig
Backup /home/osiris/.ssh/config to /home/osiris/.ssh/bak/config.1444569026
Add default to /home/osiris/.ssh/config
Add custom to /home/osiris/.ssh/config
Host server ...
Host server2 ...
Host vm2 ... 7 alias
Host vm3 ... 7 alias
Host bitbucket ... 1 alias
Host github ... 1 alias
Move /home/osiris/.ssh/config.tmp to /home/osiris/.ssh/config
Total lines: 115
Total Hosts: 24
Enable Ansible Host Generation
group lan .... 4 hosts 
group public .. 2 hosts 
source /home/osiris/.pssh_alias

The result is a file ~/.ssh/config with all hosts configurations:

cat ~/.ssh/config

Ready for ansible and parallel-ssh

By default generate a ansible hosts file:

cat /etc/ansible/hosts
[lan]
server
server2
vm2
vm3

[public]
bitbucket
github

By default generate a parallel-ssh alias file:

cat ~/.pssh_alias
alias lan='/usr/bin/parallel-ssh -i -h /home/osiris/multi-ssh-config/groups/lan'
alias lanbackup='/usr/bin/parallel-ssh -i -h /home/osiris/multi-ssh-config/groups/lan -l backuprsync'
alias public='/usr/bin/parallel-ssh -i -h /home/osiris/multi-ssh-config/groups/public'
alias publicbackup='/usr/bin/parallel-ssh -i -h /home/osiris/multi-ssh-config/groups/public -l backuprsync'

Visualization

With parameter -d generate a .dot file for Graphviz

cd ~/multi-ssh-config
./sshconfig -d

config.png