-
Notifications
You must be signed in to change notification settings - Fork 1
GIT SSH
Jason Lewis edited this page Jul 5, 2021
·
9 revisions
- Navigate to your .ssh folder, creating it if necessary. On Windows this should be under
C:\Users\Jason\.ssh
. On MacOS and Linux this will be a hidden folder at~:/.ssh
. - Execute the following command to create the key.
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- When prompted, set a name however you like.
- When prompted, enter and confirm a passphrase for the key.
- Enter the following into your
.ssh\config
file (following example is for Github)Host github.com User git Hostname github.com PreferredAuthentications publickey IdentityFile ~/.ssh/<your key name>
- Edit the ~/etc/wsl.conf
- Add the following
[automount] enabled = true root = / options = "metadata" mountFsTab = true
- Restart the instance
- Execute the commands
chmod 600 <your key name> chmod 600 config
- Open the Windows menu and type "Services"
- Find the OpenSSH Authentication Agent entry
- Right-click it and choose Properties
- Set
Startup Type
toAutomatic
- Click Okay
Should already be running. You can check with the following command
eval "$(ssh-agent -s)"
- Open your console
- Navigate to your .ssh folder
- Enter the following command:
For example, if your key name is git_rsa, execute (note no extension)
ssh-add <Your key name>
ssh-add git_rsa
- Enter the passphrase when prompted
- Open your ~/.bashrc file.
- Add the following to the end of it (be sure to replace with your key name).
Source: https://stackoverflow.com/questions/18880024/start-ssh-agent-on-login
# Load identities SSH_ENV="$HOME/.ssh/agent-environment" function start_agent { echo "Initialising new SSH agent..." /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" echo succeeded chmod 600 "${SSH_ENV}" . "${SSH_ENV}" > /dev/null /usr/bin/ssh-add ~/.ssh/<your SSH key name>; } # Source SSH settings, if applicable if [ -f "${SSH_ENV}" ]; then . "${SSH_ENV}" > /dev/null #ps ${SSH_AGENT_PID} doesn't work under cywgin ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { start_agent; } else start_agent; fi
- Restart the instance
- Open the Github console
- Open your account settings
- Click
SSH and GPG keys
- Under
SSH keys
click New SSH Key - Enter a name
- In the Key field, copy and paste the contents of your .pub file found in your .ssh folder.
- Open the Gitlab console
- Open your account settings
- Click
SSH Keys
- In the Key field, copy and paste the contents of your .pub file found in your .ssh folder.
- Enter a Title in the title field.
- You can leave the Expires At field empty.
- Click Add Key
- Sign-in to the AWS console with your user login (don't use the root account for this).
- Navigate to the IAM page.
- Click on Users in the left-hand menu.
- Click on your user entry.
- Select the Security Credentials tab.
- Under SSH Keys for AWS CodeCommit click Upload SSH Public Key.
- Copy and paste the contents of your .pub file found in your .ssh folder.
- Click the Upload SSH Public Key button.