Skip to content

Instantly share code, notes, and snippets.

@nabily4e-dev
Last active December 29, 2023 19:15
Show Gist options
  • Save nabily4e-dev/2ef771cfa0bdfef70a968fc25d820a2b to your computer and use it in GitHub Desktop.
Save nabily4e-dev/2ef771cfa0bdfef70a968fc25d820a2b to your computer and use it in GitHub Desktop.

Here we simply copy a previously existed ssh keys from another system, instead of doing all the ssh stuff!!

# change ownership of folder and contents
sudo chown nabily4e_suse:users .ssh/ .ssh/* .gitconfig
# change .ssh/ .ssh/* permissions
# change to the .ssh folder
~/.ssh/
sudo chmod 644 id_rsa.pub
sudo chmod 600 id_rsa
sudo chmod 644 known_hosts
# change out to set the folder permissions
../
sudo chmod 700 .ssh/
# authenticate with GitHub
ssh -T git@github.com

The preivous block is a series of commands that can be used to set up SSH keys for GitHub on openSUSE, a Linux distribution. SSH keys are a way of authenticating with GitHub without using a password. Here is a brief explanation of what each command does:

  • sudo chown nabily4e_suse:users .ssh/ .ssh/* .gitconfig: This command changes the ownership of the .ssh folder, its contents, and the .gitconfig file to the user nabily4e_suse and the group users. This is done to ensure that only the user nabily4e_suse can access and modify these files, which contain sensitive information such as the private SSH key and the GitHub configuration.
  • sudo chmod 644 id_rsa.pub: This command changes the permissions of the file id_rsa.pub, which is the public SSH key, to 644. This means that the owner (nabily4e_suse) can read and write the file, while the group (users) and others can only read the file. This is done to prevent unauthorized modification of the public key, which is used to verify the identity of the user nabily4e_suse when connecting to GitHub.
  • sudo chmod 600 id_rsa: This command changes the permissions of the file id_rsa, which is the private SSH key, to 600. This means that only the owner (nabily4e_suse) can read and write the file, while the group (users) and others have no access to the file. This is done to protect the private key, which is used to encrypt and decrypt the communication with GitHub, from being stolen or compromised by anyone else.
  • sudo chmod 644 known_hosts: This command changes the permissions of the file known_hosts, which is a file that stores the fingerprints of the hosts that the user nabily4e_suse has connected to via SSH. This file is used to prevent man-in-the-middle attacks, where a malicious third party tries to impersonate a legitimate host. The permissions are set to 644 to allow the owner (nabily4e_suse) to read and write the file, while the group (users) and others can only read the file.
  • sudo chmod 700 .ssh/: This command changes the permissions of the .ssh folder to 700. This means that only the owner (nabily4e_suse) can read, write, and execute files in the folder, while the group (users) and others have no access to the folder. This is done to prevent anyone else from accessing the files in the .ssh folder, which contain the SSH keys and other SSH-related configuration.
  • ssh -T git@github.com: This command tests the SSH connection to GitHub by using the SSH key pair that was set up. The -T option tells SSH not to request a shell on the remote host, but just to verify that the authentication works. If the connection is successful, the user nabily4e_suse will see a message from GitHub welcoming them and confirming their username.

from: https://nabily4e_susespence.com/posts/using-opensuse-for-webdev#add-ssh-keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment