Skip to content

TJ5: Git and SSH

dthomsen116 edited this page Feb 21, 2022 · 6 revisions

Lab Git and SSH

Common Responses

This lab was working with Git and Cloning, Pushing, and Pulling, a Git Repo. It then also uses the Git to pass a key to allow passwordless SSHing.

Notes

  • Install Git on Docker01
  • Use Git to clone the Repo
  • Create a PAT in Github to authenticate for Git
  • Now actually Clone the Repo
  • On MGMT01, Download GitBash
    • This is basically a linux shell used on Windows to run Git commands
  • Add Files on Windows, Pull them on Ubuntu
  • Generate a key pair on Web01
  • Copy this public key to the Repo
  • Pull the Repo
  • Create a new user and give it the key and permissions to SSH without a password
    • Script Syntax
#secure-ssh.sh
#author dthomsen116


#creates a new user using $1 parameter
sudo adduser $1
sudo mkdir /home/$1/.ssh

#adds a public key from a local repo or curled from the remote repo
sudo cp /home/david/Git_SSH/linux/public-keys/id_rsa.pub /home/$1/.ssh/authorized_keys
sudo chmod 700 /home/$1/.ssh
sudo chmod 600 /home/$1/.ssh/authorized_keys
sudo chown -R $1:$1 /home/$1/.ssh

#removes roots ability to ssh in on Centos
#sudo sed -i "s/PermitRootLogin yes/PermitRootLogin no" /etc/ssh/sshd_config
#sudo systemctl restart ssh sshd

Important Key Words/Commands:

Problems and Solutions

I had many issues with many parts of this lab.

First, I was working to clone my Git and didn't realize I needed my PAT. This was an issue also because I wasn't able to verify without an SSH because there is no Copy Paste.

Secondly, My docker machine bricked and now just shows a blank screen and is stuck in a boot loop. This had not caused too much issue, just had to ssh in order to use the machine.

The main issue I was unable to SSH without a password. The solution I had found was that the private key on Web01 was in the wrong directory and after a simple copy paste, my two day long error was solved.

Clone this wiki locally