Skip to content

Instantly share code, notes, and snippets.

View MarcosBernal's full-sized avatar

Marcos Bernal España MarcosBernal

View GitHub Profile
@MarcosBernal
MarcosBernal / ssh-connection-configuration-notes.md
Last active October 30, 2020 00:27
SSH configuration, key creation and key fingerprint check

Generating a key pair with ssh-genkey

  1. Generate the key with $ ssh-keygen -t rsa -b 4096 -v and when asked to enter file in which to save the key, type my-certificate and when asked to enter passphrase, press Enter (empty passphrase) and confirm by Enter.
  2. You will get two files generated, one will be my-certificate and one will be my-certificate.pub, make my-certificate on your computer read-only sudo chmod 400 my-certificate
  3. Upload the public certificate to to server: ssh-copy-id -i my-certificate.pub user@hostname
    • By default appends user key in ~/.ssh/authorized_keys of the remote machine
    • In case of requiring to force password authentication: -o PreferredAuthentications=password
  4. OPTIONAL To copy your key to your clipboard: xclip -selection clipboard < my-certificate.pub
Protect identity with keyring when using clients like git
  1. Launch ssh-agent: eval $(ssh-agent)
@MarcosBernal
MarcosBernal / pre-commit
Created November 6, 2018 16:53
Git Hook to check the .gitlab-ci.yml file before creating a commit (pre-commit). It sends the file to gitlab ci lint to check it
#!/bin/bash
###########################
# Validate .gitlab-ci.yml #
# by Peter Weinert #
###########################
# Modified version extracted from https://gitlab.lrz.de/snippets/234
GITLAB_URL="https://gitlab.com"