Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access aws config file from WSL (Windows subsystem for Linux)?

I have installed awscli and have added aws keys to the config and credentials file. Now I can access them through file explorer from Windows but I cannot access them through the WSL bash. It says permission denied when I try to cd to the .aws folder present in rootfs. How do I access them from bash?

like image 881
thedreamsaver Avatar asked Sep 08 '18 19:09

thedreamsaver


People also ask

How do I find my AWS config file in Windows?

The config file is located at ~/.aws/config on Linux or macOS, or at C:\Users\ USERNAME \.aws\config on Windows. This file contains the configuration settings for the default profile and any named profiles.

Where is the WSL config file?

wslconfig. Stored in your %UserProfile% directory. Used to configure settings globally across all installed Linux distributions running as the WSL 2 version.

How do I open a WSL file in Linux?

From Windows Command Prompt or PowerShell, you can enter the name of your installed distribution. For example: ubuntu. From Windows Command Prompt or PowerShell, you can open your default Linux distribution inside your current command line, by entering: wsl.exe .

Where is .AWS folder in WSL?

The shared AWS config and credentials files are plaintext files that reside by default in a folder named . aws that is placed in the " home " folder on your computer.


1 Answers

All you have to do is to set a couple of environment variables from the WSL shell. I am assuming that you are working with bash and Ubuntu.

export AWS_SHARED_CREDENTIALS_FILE=/mnt/c/Users/<your user name>/.aws/credentials
export AWS_CONFIG_FILE=/mnt/c/Users/<your user name>/.aws/config

If you want to make the env variables sticky add the two lines to ~/.bashrc or /etc/bash.bashrc

remember to source /etc/bash.bashrc or source ~/.bashrc after editing them.

See documentation here complete list of env variables you can work with cli-environment

like image 138
DaMightyMouse Avatar answered Oct 28 '22 05:10

DaMightyMouse