MacOS安装Homebrew、sshfs以及使用sshfs将服务器目录挂载到本地

一、安装sshfs

1、首先,用如下命令安装Homebrew,如果已经安装过则无需执行:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Homebrew官网的源都在github上,更新软件或者Homebrew速度慢到怀疑人生。所以将仓库源替换为清华镜像:清华大学开源软件镜像站,因为此前已经从官网上安装过Homebrew,所以直接执行:

# brew 程序本身,Homebrew/Linuxbrew 相同
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 以下针对 mac OS 系统上的 Homebrew
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git

# 以下针对 Linux 系统上的 Linuxbrew
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/linuxbrew-core.git

# 更换后测试工作是否正常
brew update

执行brew update的时候出现:

~ % brew update --verbose
Checking if we need to fetch /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask...
Fetching /usr/local/Homebrew...
error: Not a valid ref: refs/remotes/origin/master
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (16/16), done.
Receiving objects:   3% (14716/4819Receiving objects:   3% (14730/4819Receiving objects:   3% (14744/4819Receiving objects:   3% (14772/4819Receiving objects:   3% (14786/4819Receiving objects:   3% (14800/4819Receiving objects:   3% (14827/4819Receiving objects:   3% (14855/4819Receiving objects:   3% (14869/4819Receiving objects:   3% (14911/4819Receiving objects:   3% (14925/4819Receiving objects:   3% (14953/4819Receiving objects:   3% (14967/4819Receiving objects:   3% (14995/4819Receiving objects:   3% (15011/4819Receiving objects:   3% (15038/4819Receiving objects:   3% (15052/4819Receiving objects:   3% (15066/4819Receiving objects:   3% (15094/4819Receiving objects:   3% (15122/4819Receiving objects:   3% (15136/4819Receiving objects:   3% (15164/4819Receiving objects:   3% (15191/4819Receiving objects:   3% (15220/4819Receiving objects:   3% (15247/4819Receiving objects:   3% (15276/4819Receiving objects:   3% (15317/4819Receiving objects:   3% (15345/4819Receiving objects:   3% (15373/4819Receiving objects:   3% (15387/4819Receiving objects:   3% (15401/4819Receiving objects:   3% (15415/4819Receiving objects:   3% (15429/4819Receiving objects:   3% (15442/4819Receiving objects:   3% (15456/4819Receiving objects:   3% (15470/4819Receiving objects:   3% (15499/4819Receiving objects:   3% (15513/4819Receiving objects:   3% (15541/4819Receiving objects:   3% (15554/4819Receiving objects:   3% (15596/4819Receiving objects:   3% (15611/4819Receiving objects:   3% (15624/4819Receiving objects:   3% (15652/4819Receiving objects:   3% (15680/4819Receiving objects:   3% (15694/4819Receiving objects:   3Receiving objects:  28% (138517/481995), 34.54 MiB | 8.00 KiB/s s:   3% (16125/481995), 9.49 MiB | 8.00 KiB/s
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Fetching /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask failed!
Updating /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.

Updating /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Successfully rebased and updated refs/heads/master.

Updated 1 tap (homebrew/core).==> New Formulae
flit
==> Updated Formulae
vim ✔              deark              firebase-cli       imagemagick@6      mm-common          pc6001vx           rqlite
archiver           deno               gdcm               jsoncpp            naabu              phpstan            ruby-build
ask-cli            dependency-check   ghostscript        libsigc++          neo4j              pmd                spotbugs
aws-cdk            dvc                git-extras         libsigc++@2        neomutt            pnpm               subfinder
balena-cli         embree             hypre              libuv              ninja              podman             tre-command
bandcamp-dl        eslint             iblinter           lmod               nvm                ponyc              vault
bindfs             exploitdb          idnits             micronaut          ocrmypdf           procs              xmrig
chart-testing      ffsend             imagemagick        mikutter           packer             python-yq          zola

2、安装sshfs的依赖包fuse:

~ % brew cask install osxfuse
==> Caveats
osxfuse requires a kernel extension to work.
If the installation fails, retry after you enable it in:
  System Preferences → Security & Privacy → General

For more information, refer to vendor documentation or this Apple Technical Note:
  https://developer.apple.com/library/content/technotes/tn2459/_index.html

You must reboot for the installation of osxfuse to take effect.

==> Downloading https://github.com/osxfuse/osxfuse/releases/download/osxfuse-3.11.0/osxfuse-3.11.0.dmg
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/1867347/561bb300-bda9-11ea-8ffc-b62049894f93?X-Amz-
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'osxfuse'.
==> Installing Cask osxfuse
==> Running installer for osxfuse; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
installer: Package name is FUSE for macOS
installer: Installing at base path /
installer: The install was successful.
==> Changing ownership of paths required by osxfuse; your password may be necessary
🍺  osxfuse was successfully installed!

3、安装sshfs:

~ % brew install sshfs
==> Downloading https://homebrew.bintray.com/bottles/sshfs-2.10_2.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring sshfs-2.10_2.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/sshfs/2.10_2: 6 files, 101.8KB

4、重启电脑

5、在“偏好设置->安全与隐私性->通用”中允许xx开发者开发的软件运行。

6、使用sshfs:因为更改了IP别名,所以需要ping查看IP地址,如果自己记得的话,这步就没必要了。

二、加快Homebrew下载软件的速度:

方法一:

临时替换

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

长期替换

如果你使用 bash:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

如果你使用 zsh:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zprofile
source ~/.zprofile

方法二:

HomebrewCN中国版,以及使用过程中的常见错误

Homebrew 国内自动安装脚本

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值