This is how you can use a config.d directory in your ssh config so that you will have versatility, portability, and customization of your ssh env and commands to connect to servers using simple shortcuts from VS Code and Terminal. Manage multiple identities, keys, servers, everything.
example: ssh prototype
or ssh user1@prototype
- Make sure you have a .ssh dir with permissions 755 for the dir
- Create an SSH key and give it permissions 600
- Make an ssh config file by typing
nano ~/.ssh/config
and put in the lineInclude config.d/*
hitcntrl + x
theny
when you're done editing - Create a config.d directory
mkdir ~/.ssh/config.d
- In there, you can add in ssh config files for various projects - for exmaple,
personal
orwork
- Let's create one for work
cd ~/.ssh/config.d && nano work
- You can put your ssh config details into the file for a particular host. The line "Host" defines the name you will use to connect with ssh, Hostname is the address or FQDN to dial, User is the user account, Identity file is the path to your private key - the pub key must be in the server's ~/.ssh/authorized_keys file with the correct permissions
# Server for prototype
Host prototype 34.12.16.12
Hostname 34.12.16.12
User ubuntu
IdentityFile ~/.ssh/id_ed25519
- Save the file with
cntrl +x
theny
when you're done adding - Now type
ssh prototype
and you should connect to the server.