Categories
GIT Terminal

Setting up multiple SSH keys on Mac

1) Generate a new SSH key using the secure Ed25519 algorithm:

ssh-keygen -t ed25519 -C "your_email@example.com"

For legacy systems that don’t support that algorithm (like AWS’ CodeCommit) use the following:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

2) When prompted, change the name of the file (key pair) if you want

3) Enter a strong passphrase

4) Repeat for as many keys as you need (for example as many GitHub, BitBucket, AWS or any other service that you want to use SSH keys with)

5) Copy the SSH public key and upload it to the respective service

pbcopy < ~/.ssh/id_ed25519.pub

6) Open your ~/.ssh/config file

open ~/.ssh/config

If the file doesn’t exist, create it like this (and then open it with the previous command):

touch ~/.ssh/config

7) Write your configuration so the machine understands you have multiple keys. The host has to be unique, the hostname is the service and the identity file is the key you’ve just created. Pay attention to the values that you will be filling. Here’s an example:

# Personal GitHub account
Host github.com
 HostName github.com
 User git
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa
# Work GitHub account
Host github.com-work
 HostName github.com
 User git
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa_work

8) Add each key to your machine’s SSH agent:

ssh-add -K ~/.ssh/id_ed25519

You can list all the keys added to the agent:

ssh-add -l

9) Clone your repositories in this manner, notice the -work after the domain, you set this value up previously in the config file:

git clone git@github.com-work:Homebrew/brew.git
Categories
Terminal

Speed up the tracking of your mouse in Mac

Type this command in the terminal to check the speed you are currently using:

defaults read -g com.apple.mouse.scaling

The default value is usually 3, increase it to your hearts content with this other command. I chose 7.0 as the value I like to use:

defaults write -g com.apple.mouse.scaling  7.0

Restart your machine.

Categories
Server Terminal

Laravel’s Artisan Command Shortcuts

php artisan route:list
composer dump-autoload
Categories
Server Terminal

Don’t Forget To CHMOD 400 Your .PEM File

When trying to SSH to an AWS instance:

CHMOD 400 yourpemfile.pem
Categories
Terminal

Check If You are Running 32 or 64 bit OS X

uname -m

Categories
Terminal

Force Empty the Trash

sudo rm -rf ~/.Trash
sudo rm -rf /Volumes/*/.Trashes

Categories
Terminal

Basic Terminal Commands

Moving up a directory:

cd ..

Moving to the root:

cd

See where on the filesystem you are:

pwd

Check permissions on a specific folder:

ls -ld directory

Changing permissions (read, write and execute) for files and folder recursively:

chmod -R 777 /Users/Test/Desktop/PATH

or when inside the folder:

sudo chmod -R 777 .

Check permissions of a file/directory:

ls -la

Who you are and your group:

whoami
id

Change directory to .SSH and list keys

cd ~/.ssh/
ssh-add -l

Design a site like this with WordPress.com
Get started