HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

sshpass — An SSH password provider. It works by creating a TTY, feeding the password into it, and then redirec

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandpasswordworkssshproviderclicreatingsshpass

Problem

How to use the sshpass command: An SSH password provider. It works by creating a TTY, feeding the password into it, and then redirecting stdin to the SSH session. More information: <https://manned.org/sshpass>.

Solution

sshpass — An SSH password provider. It works by creating a TTY, feeding the password into it, and then redirecting stdin to the SSH session. More information: <https://manned.org/sshpass>.

Connect to a remote server using a password supplied on a file descriptor (in this case, stdin):
sshpass -d {{0}} ssh {{user}}@{{hostname}}


Connect to a remote server with the password supplied as an option, and automatically accept unknown SSH keys:
sshpass -p {{password}} ssh -o StrictHostKeyChecking=no {{user}}@{{hostname}}


Connect to a remote server using the first line of a file as the password, automatically accept unknown SSH keys, and launch a command:
sshpass -f {{path/to/file}} ssh -o StrictHostKeyChecking=no {{user}}@{{hostname}} "{{command}}"

Code Snippets

Connect to a remote server using a password supplied on a file descriptor (in this case, `stdin`)

sshpass -d {{0}} ssh {{user}}@{{hostname}}

Connect to a remote server with the password supplied as an option, and automatically accept unknown SSH keys

sshpass -p {{password}} ssh -o StrictHostKeyChecking=no {{user}}@{{hostname}}

Connect to a remote server using the first line of a file as the password, automatically accept unknown SSH keys, and launch a command

sshpass -f {{path/to/file}} ssh -o StrictHostKeyChecking=no {{user}}@{{hostname}} "{{command}}"

Context

tldr-pages: common/sshpass

Revisions (0)

No revisions yet.