Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For those who can't get public key authentication working #32

Closed
Ryuo1 opened this issue Feb 21, 2022 · 5 comments
Closed

For those who can't get public key authentication working #32

Ryuo1 opened this issue Feb 21, 2022 · 5 comments

Comments

@Ryuo1
Copy link

Ryuo1 commented Feb 21, 2022

First generate a key pair using ssh-keygen

  1. Get the public key (assuming it's named id_rsa.pub) from your computer (in $HOME/.ssh/ folder assuming you are on Linux), to your phone.

  2. Copy the contents of your public key inside your phone using root browser's text editor or any other text editor of your choice.

  3. Create a file named authorized_keys inside the /data/ssh/root/.ssh/ folder.

  4. Paste the contents of your public key into the authorized_keys file using the text editor of your choice.

  5. Copy that file into the /data/ssh/shell/.ssh/ folder if you want shell login too.

  6. Now to login into your phone using ssh, you need the private key (assuming it is named id_rsa) that was generated with your public key. Type this command onto your computer in the same folder as your private key file. ssh -i id_rsa root@[_your phone's local ip_]. You don't need to type the -i id_rsa if you private and public key file is in your computer's $HOME/.ssh/ folder.

You got yourself a perfectly functioning key with right permissions! (Unless you didn't follow the instructions correctly)

@ReMiOS
Copy link

ReMiOS commented Feb 21, 2022

I can't get SSH key working ( tried installing v0.14 and v0.13)

Running Magisk 24.1 and Android 10

Error when i try to login:
Server refused our key
No supported authentication methods available (server sent: publickey,keyboard-interactive)

I am positive the key is working since the same key is working on my old phone

star2lte:/data/ssh/root/.ssh # ls -al
drwx------ 2 root root 4096 2022-02-21 22:34 .
-rw------- 1 root root 398 2022-02-21 22:34 authorized_keys

@Ryuo1
Copy link
Author

Ryuo1 commented Feb 22, 2022

Which key did you copy to your phone? the public key or the private key?

@Ryuo1
Copy link
Author

Ryuo1 commented Feb 22, 2022

@ReMiOS Oh and you shouldn't directly copy the key to your phone. The key contents should be copied, and then inside your phone you create the file named authorized_keys and paste what you copied from your public key, to inside the file in your phone.

@ReMiOS
Copy link

ReMiOS commented Feb 22, 2022

Found it !

I noticed i can login when i hop from a linux server to my phone ( added that ssh key too )

So it had to be something with the SSH client.

I've upgraded my MobaXterm SSH client from v20.3 to v21.5 and now i can login directly as well

Probably due to the upgraded OpenSSL / OpenSSH

@Shadow27374
Copy link

I had to do this:
https://www.cnx-software.com/2012/07/20/how-use-putty-with-an-ssh-private-key-generated-by-openssh/

and it works with Putty.

Unfortunately it does not work with MobaXterm 21.2.

@Ryuo1 Ryuo1 closed this as completed Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants