Actions
  How to use a shared SSH config file » History » Revision 7
      « Previous |
    Revision 7/9
      (diff)
      | Next »
    
    Irene Meisel, 04/06/2020 04:58 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.dfolder inside your~/.sshfolder.
- Create symlinks (aliases) to those files, e.g.:
ln -s /home/jon/ownCloud/work/Configurations/work-ssh-config ~/.ssh/config.d/20-megaphone
ln -s /home/jon/ownCloud/work/Configurations/joseph-ssh-config ~/.ssh/config.d/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
- Add these lines anywhere in your .bashrcfile (a hidden folder in your home directory).
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
}
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.
- Create a file in ~/.ssh/config.dcalled10-global. It doesn't need to be a symlink.
- The entire contents of this file should be a line: user dennis(oruser irene).
Once the above setup is complete run ssh HOST and you should be connected.
Updated by Irene Meisel over 5 years ago · 7 revisions