How to use a shared SSH config file » History » Version 6
Jon Goldberg, 04/03/2020 04:29 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 | 5 | Jon Goldberg | ln -s /home/jon/ownCloud/work/Configurations/work-ssh-config ~/.ssh/config.d/20-megaphone |
10 | ln -s /home/jon/ownCloud/work/Configurations/joseph-ssh-config ~/.ssh/config.d/30-joseph |
||
11 | 1 | Jon Goldberg | ``` |
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 | 6 | Jon Goldberg | * 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 | ``` |
||
46 | 6 | Jon Goldberg | |
47 | If your username on your local machine isn't the same as your username on the remote machines, we'll also need to tell SSH to use a different default username. |
||
48 | * Create a file in `~/.ssh/config.d` called `10-global`. It doesn't need to be a symlink. |
||
49 | * The entire contents of this file should be a line: `user dennis` (or `user irene`). |