lmb-freiburg / Unet-Segmentation

The U-Net Segmentation plugin for Fiji (ImageJ)
https://lmb.informatik.uni-freiburg.de/resources/opensource/unet
GNU General Public License v3.0
87 stars 25 forks source link

Invalid Private Key, RSA #79

Open MBronars opened 3 years ago

MBronars commented 3 years ago

I am trying to use a backend server to run my segmentation, but I am unable to access it with my RSA key. In my standard terminal I am able to ssh into the server just fine using my private key, but for some reason I'm getting an invalid private key error when I try to pass in that file during segmentation. Not sure how to fix this, any advice would be greatly appreciated. Maybe the file needs to be in a different format for U-Net?

MBronars commented 3 years ago

Searched around on the internet a bit and found the solution, anyone else facing this issue try the following and hopefully it works like it did for me:

Cause: new openssh libs used to generate keys by default save private keys in a different file format that U-Net can't handle. New file format starts with "-----BEGIN OPENSSH PRIVATE KEY-----", while the old one has a different header "-----BEGIN RSA PRIVATE KEY-----" Solution: (copy) convert your private key file using: ssh-keygen -p -f file -m pem -P passphrase -N passphrase (if the key is not encrypted with a passphrase, use "" instead of passphrase)

It seems like you may face these issues if you are using a newer Mac as your frontend computer

lucaslovercio commented 3 years ago

Hi! I am having the same issue, in Ubuntu. the parameter file in your script is the old id_rsa location? Thanks!

lucaslovercio commented 3 years ago

Maybe more detail can help to understand our issue, and maybe someone can help us. We have this line in a ImageJ plugin, inside a loop of a folder:

call('de.unifreiburg.unet.SegmentationJob.processHyperStack', 'modelFilename=' + modeldef + ',Memory (MB):=4000,weightsFilename=' + caffemodel + ',gpuId=GPU 0,useRemoteHost=true,hostname=localhost,port=22,username=lucas,RSAKeyfile=/home/lucas/.ssh/id_rsa,processFolder=process-folder/,average=none,keepOriginal=false,outputScores=false,outputSoftmaxScores=false');

And it ask for the password every time it enters in the loop. It seems it is not recognizing the id_rsa file. After I write the password it works, until the next iteration, asking for it again.

ImageJ_ssh_password

This Plugin acutally owrk in other computer. In mine, I create the id_rsa with ssh-keygen -t rsa And when it ask for the passphrase, I put the password for my local server (Is that correct, or no password? because it actually work in both cases).

I tried after that the script in this thread, but nothing changed.

Installed software details: ssh -V returns OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017

Thoughts?

ThorstenFalk commented 2 years ago

You can login to the server using the RSA key from console? Try with a corresponding ~/.ssh/config section for your server specifying the key to use. The RSA key format is of course also relevant as MBronars described. Basically jsch supports only a limited set of authentication methods with a subset of available formats.