Magisk-Modules-Repo / ssh

ssh
180 stars 34 forks source link

Without changing permission of authorized_keys, ssh won't login #21

Open kgsrirama opened 4 years ago

kgsrirama commented 4 years ago

Though it is trivial, changing permission of authorized_keys is necessary to login to ssh A sudo chmod 600 /data/ssh/root/.ssh/authorized_keys will do the trick

Ryuo1 commented 2 years ago

It doesn't work. The way i would fix it is:

First generate a key pair using ssh-keygen

  1. Get the public key (assuming it's named _idrsa.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 _authorizedkeys inside the /data/ssh/root/.ssh/ folder.

  4. Paste the contents of your public key into the _authorizedkeys 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 _idrsa) 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)

Edit: yes the authorized_keys file should be chmod 600

kbzowski commented 1 year ago

In my case /data/ssh/shell/.ssh/authorized_keys need to have 600 and the owner needs to be shell user (when the owner was root it did not work). You can change both using total commander.

wardbeyens commented 1 year ago

It doesn't work. (And unsafe too (?)) The way i would fix it is:

First generate a key pair using ssh-keygen

  1. Get the public key (assuming it's named _idrsa.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 _authorizedkeys inside the /data/ssh/root/.ssh/ folder.
  4. Paste the contents of your public key into the _authorizedkeys 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 _idrsa) 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)

THANK YOU!!!

Can someone please put this in the Readme