To pass secrets over ssh config, follow the instructions below
On your host machine create an ssh config for your virtual machine in ~/.ssh/config as follows, and list the secrets you want to share using SendEnv
Host dev
HostName <IP Address>
User abhishekrai
IdentityFile ~/.ssh/id_rsa
SetEnv TERM="tmux-256color"
SendEnv AWS_ACCESS_KEY_ID
SendEnv AWS_ACCOUNT_NUMBER
SendEnv AWS_SECRET_ACCESS_KEY
SendEnv GITHUB_USERNAME
SendEnv GITHUB_TOKEN
SendEnv DOCKERHUB_USERNAME
SendEnv DOCKERHUB_TOKEN
Configure your virtual machine's sshd to receive the secrets from host machine by adding a config file in /etc/ssh/sshd_config.d/variables.conf as follows
AcceptEnv AWS_ACCESS_KEY_ID
AcceptEnv AWS_ACCOUNT_NUMBER
AcceptEnv AWS_SECRET_ACCESS_KEY
AcceptEnv GITHUB_USERNAME
AcceptEnv GITHUB_TOKEN
AcceptEnv DOCKERHUB_USERNAME
AcceptEnv DOCKERHUB_TOKEN
Then restart your machine's ssh sudo systemctl restart sshd