Getting started with SSH on Windows Subsystem for Linux (WSL)
February 25, 2019
code
# create file and folder structure for SSH
cd
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
# set appropriate permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
# generate SSH key
ssh-keygen -t rsa ~/.ssh/ninja
# make sure SSH is running
# eval `ssh-agent -s`
eval $(ssh-agent)
# load SSH key
ssh-add ~/.ssh/ninja
save your config
code
# save SSH host configs
touch ~/.ssh/config
chmod 600 ~/.ssh/config
nano ~/.ssh/config
add your config settings
code
# ~/.ssh/config
# server on Amazon LightSail
Host lightsail
HostName tornado.mycooldomain.com
User kunami
IdentityFile ~/.ssh/id_rsa
Port 4234
Now you can just do ssh lightsail everytime you need to connect and it'll pickup the key, host and port etc. from the saved config.
load your SSH key
code
ssh-add ~/.ssh/ninja
code
Enter passphrase for /home/tasiomind/.ssh/ninja:
Identity added: /home/tasiomind/.ssh/ninja (/home/tasiomind/.ssh/ninja)
Troubleshooting
- Gettings
Could not open a connection to your authentication agent.when trying tossh-add. Make sure that ssh agent is running by running theeval $(ssh-agent)command