Project

General

Profile

How to use a shared SSH config file » History » Version 2

Jon Goldberg, 04/01/2020 09:27 PM

1 1 Jon Goldberg
# How to use a shared SSH config file
2
3
Do the following:
4
* In the Nextcloud shared folder, locate the following files: `Configurations/work-ssh-config`, `Configurations/joseph-ssh-config`.
5
* Create a `config.d` folder inside your `~/.ssh` folder.
6
* Create symlinks (aliases) to those files, e.g.:
7
```shell
8
ln -s /home/jon/ownCloud/work/Configurations/work-ssh-config 20-megaphone
9
ln -s /home/jon/ownCloud/work/Configurations/joseph-ssh-config 30-joseph
10
```
11
12
When you're done, running `ls -l` in the `config.d` folder should look something like this (note I have a third "personal" symlink:
13 2 Jon Goldberg
14 1 Jon Goldberg
```
15
zabuntu: ~/.ssh/config.d » ls -l                                                                                                                                                                                                  
16
total 0
17
lrwxrwxrwx 1 jon jon 43 Oct 20  2016 10-personal -> /home/jon/ownCloud/personal/ssh/10-personal
18
lrwxrwxrwx 1 jon jon 54 May 21  2017 20-work -> /home/jon/ownCloud/work/Configurations/work-ssh-config
19
lrwxrwxrwx 1 jon jon 56 Nov 27  2017 30-joseph -> /home/jon/ownCloud/work/Configurations/joseph-ssh-config
20
```
21
22
* Finally, add these lines anywhere in your `.bashrc` file (a hidden folder in your home directory).
23 2 Jon Goldberg
24 1 Jon Goldberg
```shell
25
function ssh()
26
{
27
    ssh-combine; /usr/bin/ssh $@
28
}
29
30
function rsync()
31
{
32
    ssh-combine; /usr/bin/rsync $@
33
}
34
35
function scp()
36
{
37
    ssh-combine; /usr/bin/scp "$@"
38
}
39
40
function ssh-combine()
41
{
42
    cat $HOME/.ssh/config.d/* > $HOME/.ssh/config
43
}
44
```