Project

General

Profile

How to use a shared SSH config file » History » Revision 4

Revision 3 (Jon Goldberg, 04/02/2020 08:53 PM) → Revision 4/9 (Jon Goldberg, 04/02/2020 08:54 PM)

# How to use a shared SSH config file 

 Do the following: 
 * In the Nextcloud shared folder, locate the following files: `Configurations/work-ssh-config`, `Configurations/joseph-ssh-config`. 
 * Create a `config.d` folder inside your `~/.ssh` folder. 
 * Create symlinks (aliases) to those files, e.g.: 

 ```shell 
 ln -s /home/jon/ownCloud/work/Configurations/work-ssh-config ~/.ssh/20-megaphone 20-megaphone 
 ln -s /home/jon/ownCloud/work/Configurations/joseph-ssh-config ~/.ssh/30-joseph 30-joseph 
 ``` 

 When you're done, running `ls -l` in the `config.d` folder should look something like this (note I have a third "personal" symlink: 

 ``` 
 zabuntu: ~/.ssh/config.d » ls -l                                                                                                                                                                                                   
 total 0 
 lrwxrwxrwx 1 jon jon 43 Oct 20    2016 10-personal -> /home/jon/ownCloud/personal/ssh/10-personal 
 lrwxrwxrwx 1 jon jon 54 May 21    2017 20-work -> /home/jon/ownCloud/work/Configurations/work-ssh-config 
 lrwxrwxrwx 1 jon jon 56 Nov 27    2017 30-joseph -> /home/jon/ownCloud/work/Configurations/joseph-ssh-config 
 ``` 

 * Finally, add these lines anywhere in your `.bashrc` file (a hidden folder in your home directory). 

 ```shell 
 function ssh() 
 { 
     ssh-combine; /usr/bin/ssh $@ 
 } 

 function rsync() 
 { 
     ssh-combine; /usr/bin/rsync $@ 
 } 

 function scp() 
 { 
     ssh-combine; /usr/bin/scp "$@" 
 } 

 function ssh-combine() 
 { 
     cat $HOME/.ssh/config.d/* > $HOME/.ssh/config 
 } 
 ```