~/CyberRef$


Secure Shell (SSH)

The secure shell (SSH) protocol was originally invented by Tatu Ylonen. It is wildly popular today and used to securely connect to remote systems over port 22.

Ylonen was inspired to create the protocol after a password sniffer siphoned up unencrypted login credentials from the Finnish University network back in 1995!

You may read more about the history of this protocol at ssh.com.

Generating a Key Pair

The command ssh-keygen will generate a key pair. It is extremely important to keep track of your key pairs.

You may further specify the algorithm using -t, key size using -b, passphrase (optional) using -N, and file using -f. If you use a passphrase, it will encrypt your private key on your device and you will need to enter the passphrase when using your key. Here's a basic example of generating a ssh key pair using the recommended Elliptic Curve Digital Signature Algorithm with 512 bits:

ssh-keygen -t ecdsa -b 512 -N myT0t@lly_S3cure-K3yLo1 -f yourKeyFile

Connecting with SSH

Although ssh permits connecting with a traditional password, using a key pair is much safer. To do this, first you need to upload your public key (which will end in .pub) to the remote host.

ssh-copy-id -i yourKeyFile.pub yourUsername@remoteHost

Afterwards, you may simply connect by running:

ssh -i yourKeyFile yourUsername@remoteHost

As a more tangible demonstration, here's an example highlighting pwn.college:

ssh -i yourPwnCollegeKey hacker@dojo.pwn.college

If you set a passphrase, you will also be prompted for it as well. When connecting to a remote host, it is checking your private key against the public (.pub) key you provided.

References

https://www.ssh.com/academy/ssh

https://www.ssh.com/academy/ssh/keygen

https://linuxize.com/post/ssh-copy-id-command/