scripts
scripts copied to clipboard
Authentication without password using OpenSSH Key, certificates .pem and .pub
Based on this tutorial.
How to generate a Key Pair for authentication without password
ssh-keygen -t rsa -b 2048 -v
We have to add the keyname migonzagpup100_rsa:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/miguel/.ssh/id_rsa): /Users/miguel/.ssh/migonzagpup100_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/miguel/.ssh/migonzagpup100_rsa.
Your public key has been saved in /Users/miguel/.ssh/migonzagpup100_rsa.pub.
The key fingerprint is:
SHA256:2VVHKEfxyzrawPDUzrYvK/WbMLlvYK/6PzUBCKoWmW4 [email protected]
The key's randomart image is:
You get two files, migonzagpup100_rsa.pub and migonzagpup100_rsa.
Uploading the generated certificate from client computer to server
Then we need to copy the public key to the server
ssh-copy-id -i /Users/miguel/.ssh/migonzagpup100_rsa.pub [email protected]
Now we make sure that we can log in using the private key (without the password):
ssh -i /Users/miguel/.ssh/migonzagpup100_rsa [email protected]
Authenticating directly through hostname
You can create the file ~/.ssh/config and add the following lines:
Host migonzagpup100 migonzagpup100.westeurope.cloudapp.azure.com
Hostname migonzagpup100.westeurope.cloudapp.azure.com
User hoaphumanoid
IdentityFile /Users/miguel/.ssh/migonzagpup100_rsa
Host migonzagpup100london migonzagpup100london.westeurope.cloudapp.azure.com
Hostname migonzagpup100london.westeurope.cloudapp.azure.com
User hoaphumanoid
IdentityFile /Users/miguel/.ssh/migonzagpup100london
Now you can ssh to the machine directly by using the hostname: ssh migonzagpup100.