Skip to content

Instantly share code, notes, and snippets.

@GillyRabutTsurwa
Created May 23, 2024 17:50
Show Gist options
  • Save GillyRabutTsurwa/41e831fdfccf943464f4ad7ba7bc2139 to your computer and use it in GitHub Desktop.
Save GillyRabutTsurwa/41e831fdfccf943464f4ad7ba7bc2139 to your computer and use it in GitHub Desktop.
Notes from Jay's 1.5 Hour SSH Lesson

SSH Commands

To connect to a server, use the SSH command, along with the server user and IP address

ssh username@12.34.56

To generate a SSH key, use the ssh-keygen command

ssh-keygen

There are two ways to add your SSH Key to your remote server

Method #1

  • Go to your remote server
  • Go to your .ssh directory, which is likely in your home directory. Create it if it doesn't exist
    • cd ~/.ssh
  • Create a file named authorized_keys there within
  • Paste your public key that will be used to connect to that server. The private key stays in your server/machine
  • Restart your connection

Method #2

  • The second, and more effecient way is by using the ssh-copy-id command
  • ssh-copy-id -i ~/.ssh/my_key.pub username@12.34.56
  • in this command we use the -i flag to specify the public key we want to add to our remote server
  • the next part of the command is the path to the public key
  • and the final part is the remote server in which we want the public key to be added
  • this yields the same exact result as method #1 (you will see an authorized_keys file with your public key within)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment