标签:OSX

OSX 安装APP Store 以外应用

MAC OSX(10.12.6)以后版本的【安全性与隐私】中 APP Store 【任何来源】突然不见了。
如果有些应用不能安装,提示【移动到废纸篓】,可以打开终端输入:

sudo spctl --master-disable

按提示输入用户密码后回车。
这时再去看这个选项就出现并选择了。
PS:我试验了下,在终端输入

sudo spctl --master-enable

还可以隐去它


Git避免每次push都需要输入passphrase for key

在 OSX 中,可以以使用 ssh-add -K ~/.ssh/id_rsa 实现

参考 github 的帮助

Adding your SSH key to the ssh-agent
Before adding a new SSH key to the ssh-agent to manage your keys, you should have checked for existing SSH keys and generated a new SSH key.When adding your SSH key to the agent, use the default macOS ssh-add command, and not an application installed by homebrew, or some other external source.
1.Start the ssh-agent in the background.
2.If you’re using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.
3.Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa

Note: The -K option is Apple’s standard version of ssh-add, which stores the passphrase in your keychain for you when you add an ssh key to the ssh-agent.
If you don’t have Apple’s standard version installed, you may receive an error. For more information on resolving this error, see “Error: ssh-add: illegal option — K.”
4.Add the SSH key to your GitHub account.


OSX公钥方式登录Linux

打开终端后输入下面的命令:

ssh-keygen -t rsa -b 4096 -C 'test'
# 其中 -t表示加密类型,这里使用rsa
# -b表示加密位数
# -C表示备注信息

系统会出现如下提示:

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/(你的登陆用户名)/.ssh/id_rsa):

这里回车即可
系统会接着提示:

Enter passphrase (empty for no passphrase):

这里是输入一个秘钥密码,可输入可不输入。如果输入使用秘钥时会要求输入这个密码
完成后会生成两个文件,id_rsa和id_rsa.pub文件。其中id_rsa为私钥文件,需要保存好,被别人获取的话别人也一样可以登录你的服务器。
这样将公钥上传到你的 Linux 服务器,这样就可以实现免密登陆了。

如果想更简单:
首先在.ssh下增加一个文件config

touch config

在config中添加如下服务器别名、登录信息:

cat config
Host        myhost #别名
HostName    testhost
Port        822
User        test
IdentityFile    ~/.ssh/id_rsa

如果有很多服务器要添加,只要直接在config中另起一段增加以上内容即可。
文件建立完成之后,就可以使用了

ssh myhost
Last login: Sun Jan 17 22:31:31 2016 from xxx.xx.xx.xxxx
[test@myhost ~]$

为了更安全,我们还可以操作如下内容,不过一定要保证以上登陆已经成功
编辑/etc/sshd_config文件

PermitEmptyPasswords no
PasswordAuthentication no
PermitRootLogin no
Port 822