Skip to content

M4 / macOS Sequioa 15.4.1 へ sshpass をインストールする

以前に以下のメモを書きました。

現在は Homebrew Formulae で sshpass が公開されている ようです。 簡単ですが、インストール手順をメモしておきます。

検証環境

検証は M4 Mac mini で行いました。

対象 バージョン
macOS Sequoia 15.4.1
sshpass 1.10

インストール

下記をインストールするだけでインストール出来ます。

brew install sshpass

バージョン 1.10 がインストールされました。

% sshpass -V
sshpass 1.10
(C) 2006-2011 Lingnu Open Source Consulting Ltd.
(C) 2015-2016, 2021-2022 Shachar Shemesh
This program is free software, and can be distributed under the terms of the GPL
See the COPYING file for more information.

Using "assword" as the default password prompt indicator.
% brew info sshpass
==> sshpass: stable 1.10 (bottled)
Non-interactive SSH password auth
https://sourceforge.net/projects/sshpass/
Installed
/opt/homebrew/Cellar/sshpass/1.10 (9 files, 83.2KB) *
  Poured from bottle using the formulae.brew.sh API on 2025-05-04 at 09:21:41
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/s/sshpass.rb
License: GPL-2.0-only
==> Caveats
Sshpass is a tool for non-interactively performing password authentication
with SSH's so called "interactive keyboard password authentication".
Most users should use SSH's more secure public key authentication instead.

See `man sshpass` for more information.
==> Analytics
install: 1,858 (30 days), 5,682 (90 days), 22,468 (365 days)
install-on-request: 1,858 (30 days), 5,676 (90 days), 22,456 (365 days)
build-error: 0 (30 days)

使い方

以下のように使います。

sshpass -p PASSWORD ssh USERNAME@ADDRESS

SSH の初回アクセス時に Fingerprint の確認を要求される処理を省略したい場合は ~/.ssh/config へ以下を追記します。 但し、当然ながらセキュリティを低下させることになりますので、留意が必要です。

~/.ssh/config
Host *
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null