1# create file and folder structure for SSH
2cd
3mkdir ~/.ssh
4touch ~/.ssh/authorized_keys
5
6# set appropriate permissions
7chmod 700 ~/.ssh
8chmod 600 ~/.ssh/authorized_keys
9
10# generate SSH key
11ssh-keygen -t rsa ~/.ssh/ninja
12
13# make sure SSH is running
14# eval `ssh-agent -s`
15eval $(ssh-agent)
16
17# load SSH key
18ssh-add ~/.ssh/ninja
1# save SSH host configs
2touch ~/.ssh/config
3chmod 600 ~/.ssh/config
4nano ~/.ssh/config
add your config settings
# ~/.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.
1ssh-add ~/.ssh/ninja
Enter passphrase for /home/aamnah/.ssh/ninja:
Identity added: /home/aamnah/.ssh/ninja (/home/aamnah/.ssh/ninja)
Could not open a connection to your authentication agent.
when trying to ssh-add
. Make sure that ssh agent is running by running the eval $(ssh-agent)
command