Project

General

Profile

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

Jon Goldberg, 04/02/2020 08:53 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 3 Jon Goldberg
8 1 Jon Goldberg
```shell
9
ln -s /home/jon/ownCloud/work/Configurations/work-ssh-config 20-megaphone
10
ln -s /home/jon/ownCloud/work/Configurations/joseph-ssh-config 30-joseph
11
```
12
13
When you're done, running `ls -l` in the `config.d` folder should look something like this (note I have a third "personal" symlink:
14 2 Jon Goldberg
15 1 Jon Goldberg
```
16
zabuntu: ~/.ssh/config.d » ls -l                                                                                                                                                                                                  
17
total 0
18
lrwxrwxrwx 1 jon jon 43 Oct 20  2016 10-personal -> /home/jon/ownCloud/personal/ssh/10-personal
19
lrwxrwxrwx 1 jon jon 54 May 21  2017 20-work -> /home/jon/ownCloud/work/Configurations/work-ssh-config
20
lrwxrwxrwx 1 jon jon 56 Nov 27  2017 30-joseph -> /home/jon/ownCloud/work/Configurations/joseph-ssh-config
21
```
22
23
* Finally, add these lines anywhere in your `.bashrc` file (a hidden folder in your home directory).
24 2 Jon Goldberg
25 1 Jon Goldberg
```shell
26
function ssh()
27
{
28
    ssh-combine; /usr/bin/ssh $@
29
}
30
31
function rsync()
32
{
33
    ssh-combine; /usr/bin/rsync $@
34
}
35
36
function scp()
37
{
38
    ssh-combine; /usr/bin/scp "$@"
39
}
40
41
function ssh-combine()
42
{
43
    cat $HOME/.ssh/config.d/* > $HOME/.ssh/config
44
}
45
```