# How to query ssh/scp password from GUI?



## Ubivetz (Mar 19, 2007)

Hi All!

I'm writing Finder plug-in with Automator (it invokes shell script listed below), which will get archives from remote host and unpack them to the current directory.
But ssh will prompt for password! For some reasons, authentification without password is impossible.
#!/bin/bash 

USERNAME="Ubivetz" 
HOST=Ubivetz@top_secret 

echo "Move all files and folders from $USERNAME/topka directory at developers' machine to $(pwd) and unpack them" 

scp $HOST:$USERNAME/topka/* . && \ # get files 
for i in $(ls *.7z); do 7za x $i; rm -f $i; done # unpack them and remove arhives 

if [ $? -eq 0 ]; then # if everything is fine, remove arhives at the remote host 
ssh $HOST "cd $USERNAME/topka && rm -f *.7z" 
fi


----------



## ora (Mar 19, 2007)

Ubivetz said:


> For some reasons, authentification without password is impossible.



Am not a shell guru, but isn't this just a matter of setting up ssh to use a key not a password. Maybe you have to set that up manually in the shell, then the script can ignore the authentication, and just invoke ssh user@server.com etc etc.


----------



## rwilkerson (Mar 19, 2007)

Yep, you have to set up key authentication for ssh.  I blogged the process here.


----------



## Ubivetz (Mar 19, 2007)

rwilkerson said:


> Yep, you have to set up key authentication for ssh.  I blogged the process here.


I've setup key authentification for all hosts, but for that host I couldn't


----------



## rwilkerson (Mar 19, 2007)

You couldn't set it up or you set it up and it didn't work?  I included a troubleshooting hint for an issue I bumped into.  Open the authorized_keys file on the remote server and look at the public key you added.  At the end you'll see user@host.  Change the host name to the IP address and see if that helps.


----------



## Ubivetz (Mar 19, 2007)

rwilkerson said:


> You couldn't set it up or you set it up and it didn't work?  I included a troubleshooting hint for an issue I bumped into.  Open the authorized_keys file on the remote server and look at the public key you added.  At the end you'll see user@host.  Change the host name to the IP address and see if that helps.


How? My local host situated behind the NAT. I have no real IP


----------



## billbaloney (Mar 19, 2007)

Did you try an ssh -v (or -v -v) to see what's failing?  Or do you know what's failing already?


----------



## Ubivetz (Mar 20, 2007)

billbaloney said:


> Did you try an ssh -v (or -v -v) to see what's failing?  Or do you know what's failing already?


I've changed remote host IP to the fake one.

OpenSSH_4.5p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /Users/Ubivetz/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 152.31.18.12 [152.31.18.12] port 22.
debug1: Connection established.
debug1: identity file /Users/Ubivetz/.ssh/identity type -1
debug1: identity file /Users/Ubivetz/.ssh/id_rsa type 1
debug1: identity file /Users/Ubivetz/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.8.1p1
debug1: match: OpenSSH_3.8.1p1 pat OpenSSH_3.*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.5
debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '152.31.18.12' is known and matches the RSA host key.
debug1: Found key in /Users/Ubivetz/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/Ubivetz/.ssh/identity
debug1: Offering public key: /Users/Ubivetz/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /Users/Ubivetz/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password
geek@152.31.18.12's password:


----------



## Ubivetz (Mar 20, 2007)

But this connection succeeded (I've changed real IP to the fake one too):

[MyMac@Ubivetz$]  ssh -v geek@152.31.18.9

OpenSSH_4.5p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /Users/Ubivetz/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 152.31.18.9 [152.31.18.9] port 22.
debug1: Connection established.
debug1: identity file /Users/Ubivetz/.ssh/identity type -1
debug1: identity file /Users/Ubivetz/.ssh/id_rsa type 1
debug1: identity file /Users/Ubivetz/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.8.1p1
debug1: match: OpenSSH_3.8.1p1 pat OpenSSH_3.*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.5
debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '152.31.18.9' is known and matches the RSA host key.
debug1: Found key in /Users/Ubivetz/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/Ubivetz/.ssh/identity
debug1: Offering public key: /Users/Ubivetz/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Warning: No xauth data; using fake authentication data for X11 forwarding.
debug1: Requesting X11 forwarding with authentication spoofing.
*******************************************************************************
*5-5                                                                          *
*                                                                             *
*                    ===================                                      *
*  Welcome to        ====  dev03  ====                                      *
*                    ===================                                      *
*                                                                             *
*  AIX Version 5.2!                                                           *
*  Please see the README file in /usr/lpp/bos for information pertinent to    *
*  this release of the AIX Operating System.                                  *
*                                                                             *
*                                                                             *
*******************************************************************************


----------

