

This assumes that you have stored the password in the keychain in the way I have described in the question usr/bin/security find-internet-password -a "$SSH_PASSWORD_USER" -s "$SSH_PASSWORD_HOSTNAME" -r "ssh " -g 2>&1 1>/dev/null | cut -d\" -f2 To get the password from the keychain, this is what it needs to look like (I call it get-ssh-password.sh): #!/bin/bash If this doesn't work for you, try Daniel's solution.įirst we need to set the SSH_ASKPASS environment variable - its value should be the path to a program which prints the password to standard output. Note that I have only tested this with OS X Lion 10.7.2. I found a solution (thanks to Daniel Beck for providing the key info needed for this). ssh-yourhostname to connect, having it retrieve and enter the password automatically. Sshpass -p"$SSHPASSWORD" ssh this in a shell function and you can just type e.g.


Execute using a line like the following: sshpass -pYourPassword ssh can read the password from security just before doing that, and use it like this: SSHPASSWORD=$( security find-generic-password -l password-item-label -g 2>&1 1>/dev/null | cut -d'"' -f2 ) Now the program is installed to /usr/local/bin/sshpass.
#Ssh copy id mac os x install
Run make install (you might need sudo for it).Open a shell to the directory sshpass-1.05.I downloaded, compiled and installed sshpass and it worked perfectly. You can, of course, redirect it to a file to log output of the program you start. Ls (on the ssh command line) is the command executed when ssh has logged in, and its output is printed in Automator. Security find-generic-password -l password-item-label -g 2>&1 1>/dev/null | cut -d'"' -f2 You can use security to read from your keychain instead, like this: #!/usr/bin/env bash In this case, we just skipped the window, returning the password from our program. This is intended to be used in graphical environments, so that a window can pop up asking for your password. When there is no tty, but SSH_ASKPASS and DISPLAY (for X11, set by default) are set, SSH executes the program specified by SSH_ASKPASS and uses its output as password. Then, set the SSH_ASKPASS environment variable to the path to this program, and then run ssh in the Automator action, like this: export SSH_ASKPASS=/Users/danielbeck/pwd.sh the following bash script you need to make executable using chmod +x pwd.sh: #!/usr/bin/env bash You need to create a program that when called prints the password to standard out, e.g. as part of a Run Shell Script action in Automator. If you don't need to have an interactive session on the remote server, you can execute ssh in an environment without tty, e.g. The scheme I use in keychain looks like this.Is there anyway I can login to this server without having to enter the password every time? Ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory However when I try to run it ssh exits with the following error: ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory Now I can retrieve the password automatically from the keychain using /usr/bin/security, however I can't find a way to send this password to the ssh prompt. I have added the passwords to the OS X keychain. And I don't want to type the passwords every time. I need to login to an ssh server which doesn't support key based authentication.
