Showing posts with label Mac OS. Show all posts
Showing posts with label Mac OS. Show all posts

Wednesday, December 09, 2020

managing multiple SSH keys

 Let's say you have already generated an SSH key for GitHub, as instructed here:

https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

Now your .ssh folder will be like this:

PHS015945:.ssh xd010$ ll

-rw-r--r--  1 xd010  staff   165B Dec  9 23:21 config

-rw-------  1 xd010  staff   411B Dec  9 23:12 id_ed25519

-rw-r--r--  1 xd010  staff   100B Dec  9 23:12 id_ed25519.pub

where config file will be like:

Host *

  AddKeysToAgent yes

  UseKeychain yes

  IdentityFile ~/.ssh/id_ed25519

Now, you want to ssh to your HPC server without a password. You will follow instructions like this http://www.linuxproblem.org/art_9.html, e.g. 

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Now append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password: 

You will find that you are still asked to enter the password when you want to ssh to your HPC. Where's the problem?

Friday, September 13, 2019

Note on the case-insensitive file system in Mac OS

I recently noticed that when my script wrote a file (e.g. condition_pd_vs_hc.pdf) into the Linux server disk mounted in my Mac. It will override another existing file although with different file name (e.g. CONDITION_PD_vs_HC.pdf). It turned out that my Mac OS filesystem is HFS+ and the disk was formated as "Mac OS Extended" (by default). Unlike "Mac OS Extended (Case-sensitive, Journaled)", "Mac OS Extended" is not case-sensitive, but case-presertive. "This means that the file system will consider foo and FoO to be the same, but when you create a new file it will remember which letters where capitalized and which were not." (quoted from https://apple.stackexchange.com/a/22304).

I totally don't get the point to have a case-insensitive but case-preserving file system.  Bummer!

Monday, January 27, 2014

Install GNU in Mac OS

If you don't know what's GNU, check here (http://www.gnu.org/gnu/gnu.html) and here (http://en.wikipedia.org/wiki/GNU).

Why Mac OS does not come with GNU? Here is what I extracted from Hong Xu's comment:
Because OS X is mainly BSD based -- the same reason why FreeBSD/OpenBSD/NetBSD does not use GNU tools by default. Another reason that Apple bundles many outdated GNU software (bash, gdb, etc.) is that the new GPLv3 doesn't allow Apple to do so, while GPLv2 is fine with this behavior. After many GNU projects upgraded to GPL v3, Apple won't be able to bundle them any more.
I found it's very easy to install GNU in Max OS just following Hong Xu's blog:
http://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/

Also recommend the friendly tool of Homebrew:
http://brew.sh/

Basically, here is step:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

brew install coreutils  # contain most of what you want
brew install binutils 
brew install diffutils 
brew install ed --default-names 
brew install findutils --default-names 
brew install gawk 
brew install gnu-indent --default-names 
brew install gnu-sed --default-names 
brew install gnu-tar --default-names 
brew install gnu-which --default-names 
brew install gnutls --default-names 
brew install grep --default-names 
brew install gzip 
brew install screen 
brew install watch 
brew install wdiff --with-gettext 
brew install wget