atsign-foundation / noports

Connect to any device with no external listening ports open
https://noports.com
BSD 3-Clause "New" or "Revised" License
272 stars 15 forks source link

If authorized_keys does not exist then the -s function does not work.. #13

Open cconstab opened 2 years ago

cconstab commented 2 years ago

Describe the bug If you want to send your public key to the server using -s then it only works if the authorized_keys file is already in place.

To Reproduce Steps to reproduce the behavior:

  1. First I deleted authorized_keys file on the sever in .ssh
  2. Then I used the -s option on the client but are still prompted for a password
  3. Checking the log you see the issue
  4. touching the file then re running everything works as it should

Expected behavior If the file does not exist then the server should create it

logs

INFO|2022-05-21 20:12:05.567675| sshnpd |ssh Public Key recieved from @colin notification id : f7ad4dc8-f0da-4484-8b09-f5ac407caa82 

SEVERE|2022-05-21 20:12:05.569308| sshnpd |Error writting to pi .ssh/authorized_keys file : FileSystemException: Cannot open file, path = '/home/pi/.ssh/authorized_keys' (OS Error: No such file or directory, errno = 2)      

 INFO|2022-05-21 20:12:07.864150| sshnpd |ssh callback request recieved from @colin notification id : 763452cc-45e7-47bc-99a9-5ec6d7ed38d1

Smartphone (please complete the following information):

cconstab commented 2 years ago

A quick note on why this is not as simple as it might seem..

Dart has no way to check/change file permissions (I know that sounds odd!) but it is true..

The file can be created but there is no way in Dart to fix the permissions to 0600 in Linux/Unix/BSD.

I could cheat and use chmod I guess but that sorta ugly..

Ideas welcome !