Forum Archive

Stash, SCP, and ssh-keygen

ihf

I would like to use SCP under Stash but it is looking for keys. I know there is an ssh-keygen command but what exactly do I need to do in order to use scp?

ihf

If I try to do:

scp user@host:/file .

I get:

stash:: No authentication methods available

Can anyone please help me get this working?

JonB

It seems to me you need to run ssh-keygen, then copy the resulting key to your host's authorized_keys. @briarfox might have some better advice, as he wrote the module.

ihf

Perhaps @briarfox can advise but what I did was run ssh-keygen -t rsa which generated a public and private key in the .ssh directory (in the stash-master directory). I then copied the .pub key to my mac (into the /Users/userid/.ssh directory). If I then try to run ssh to userid@macaddr I get "looking for SSH keys...No SSH key found///Auth Error Connection failed. Where did I go wrong?

JonB

One thing I found was that the try/except near the connect catches all error, not just auth errors, and reports as no ssh key found.

Also, Try using dsa, rather than rsa. You could also try moving the keys to ~/.ssh, as paramiko does fallback to that folder.

ihf

@JonB I created dsa keys and I moved the keys to ~/.ssh (on iPad). No luck. I get:

Connecting...
Looking fro SSH keys...
No SSH key found. Trying password...
No handlers could be found for logger "paramiko.transport"
Auth Error
Conection failed

ywangd

@briarfox is the author of the ssh tools. So I'll just try answer this as best as I can.

  • The ssh key files should be generated inside the stash installation root, i.e. $STASH_ROOT/.ssh/

  • ssh.py can take password from command line while scp can only rely on key files. I have now modified scp to ask for password if key files cannot be found. The changes are now pushed to the dev branch.

  • However both ssh and scp still failed to connect. ssh-keygen also failed to generate key files. I am not exactly what went wrong. They use to work for Pythonista 1.5. But I have not used them extensively. So I don't know when exactly they stopped working.

I'll look into it further when time permits and hopefully @briarfox can shed more light on it.

ovrCaffeinatd

ssh -vvv for verbose logging - also, keep in mind ssh is very picky about file and directory modes when choosing authentication methods.
.ssh: 700
private key: 600
public key: 644

ywangd

@ihf I fixed the bugs with ssh and scp in the latest push. You can get them with just selfupdate.

You can use scp like the follows:

scp LOCAL_FILE   USER@REMOTE_HOST:/PATH

If no SSH key is found, it will prompt for password.

The first time you run scp or ssh, it will install the latest paramiko module and ask for Pythonista restart. It will work normally afterwards.