SSH does not work after upgraded macOS sierra?

If you ever met the following errors when trying to git or ssh after upgraded your OS to sierra:

Unable to negotiate with legacyhost: no matching host key type found. Their offer: ssh-dss

Just relax, it’s not your fault but your server’s fault. Upgrading your OS to sierra will also bump your OpenSSH from version 6.9 to 7.2. According to the document of OpenSSH 7 (

OpenSSH 7.0 and greater similarly disable the ssh-dss (DSA) public key algorithm. It too is weak and we recommend against its use. It can be re-enabled using the HostKeyAlgorithms configuration option:

ssh -oHostKeyAlgorithms=+ssh-dss user@legacyhost

or in the ~/.ssh/config file:

    HostKeyAlgorithms +ssh-dss

However, it is probably not enough. You may be prompted for password all the time but no password is correct. In that case, you can simply append another line in your ~/.ssh/config file:

    PubkeyAcceptedKeyTypes +ssh-dss

That’s it! Don’t forget to restart your sshd service before retrying.

Split a subfolder out into a new repository

If you want to turn a folder within a Git repository into a brand new repository, and you don’t want to lose any of your Git history or changes, you can use git filter-branch command. For example,

git filter-branch --prune-empty --subdirectory-filter SUBFOLDER_NAME master

All the other files but the subfolder would be removed. Now you can add a new remote and then push it to your new location.

Merge existing repository into a subdirectory/subfolder

How to merge an existing repository into a new subdirectory of the current repository?

Here is the answer!

If the exist repo path is: /path/to/ex/repo, and you can give it a new name such as: ExRepo

If you want to import this repo to the current repository as sub-directory SubDir:

  1. git remote add -f ExRepo /path/to/ex/repo
  2. git merge -s ours –no-commit ExRepo/master
  3. git read-tree –prefix=SubDir/ -u ExRepo/master
  4. git commit -m “Merge ExRepo as our subdirectory SubDir

It’s done! Just four lines. What do these steps mean?

  1. fetch the other project “ExRepo
  2. prepare for the later step to record the result as a merge
  3. read “master” branch of ExRepo to the subdirectory “SubDir
  4. record the merge result

You may commit exist changes first if you have got the error “Merge with strategy ours failed“.

One more thing, how to update SubDir after merging is simple the same. Just type:

  1. git pull -s subtree ExRepo master

Enjoy & Good lock!