Project

General

Profile

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

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
```
14
zabuntu: ~/.ssh/config.d » ls -l                                                                                                                                                                                                  
15
total 0
16
lrwxrwxrwx 1 jon jon 43 Oct 20  2016 10-personal -> /home/jon/ownCloud/personal/ssh/10-personal
17
lrwxrwxrwx 1 jon jon 54 May 21  2017 20-work -> /home/jon/ownCloud/work/Configurations/work-ssh-config
18
lrwxrwxrwx 1 jon jon 56 Nov 27  2017 30-joseph -> /home/jon/ownCloud/work/Configurations/joseph-ssh-config
19
```
20
21
* Finally, add these lines anywhere in your `.bashrc` file (a hidden folder in your home directory).
22
```shell
23
function ssh()
24
{
25
    ssh-combine; /usr/bin/ssh $@
26
}
27
28
function rsync()
29
{
30
    ssh-combine; /usr/bin/rsync $@
31
}
32
33
function scp()
34
{
35
    ssh-combine; /usr/bin/scp "$@"
36
}
37
38
function ssh-combine()
39
{
40
    cat $HOME/.ssh/config.d/* > $HOME/.ssh/config
41
}
42
```