ACCESS-NRI / access-hive.org.au

Documentation hub for the Earth System models, ACCESS, and their community
https://access-hive.org.au/
8 stars 11 forks source link

Login to Gadi: automatic ssh Linux instructions #725

Closed leonardolaiolo closed 2 months ago

leonardolaiolo commented 2 months ago

Description

I noticed a couple of tweaks were needed for Linux/Windows users (I couldn't managed to make it work just following the instructions https://access-hive.org.au/getting_started/first_steps/#login-to-gadi).

Why

Errors are related to:

Close Criteria

Instructions are updated

atteggiani commented 2 months ago

Hi @leonardolaiolo, Thank you for opening this issue!

We will review this problem and find a possible solution.

atteggiani commented 2 months ago
  • The command ssh gadi "cat >> .ssh/authorized_keys <<< '$(cat ~/.ssh/id_gadi.pub)'" fails. This command worked from my local Linux machine cat ~/.ssh/id_gadi.pub | ssh gadi 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'

@leonardolaiolo Can you be more specific on why the command failed? What error did you get?

I see in the command that worked you created the .ssh directory. Is the absence of the .ssh directory the reason why the previous command failed?

leonardolaiolo commented 2 months ago

Hi Davide, i think there may be 2 issues there. 1 - first error I was getting: /home/leonardo/.ssh/config: line 10: Bad configuration option: usekeychain. I think UseKeychain option is specific to macOS, but it isn't recognised in Linux. 2 - after fixing the first issue with UseKeychain I was getting a different error: /bin/bash: .ssh/authorized_keys: No such file or directory when I was running ssh gadi "cat >> .ssh/authorized_keys <<< '$(cat ~/.ssh/id_gadi.pub)'". But when I was doing a cat .ssh/authorized_keys it showed a key. I was clueless then I asked ChatGPT, that suggested the ssh command is not correctly interpreting the redirection and appending the public key to the authorized_keys file on the remote server. The cat >> redirection needs to be properly understood by the shell on the remote system. Hope this helps?

atteggiani commented 2 months ago

1 - first error I was getting: /home/leonardo/.ssh/config: line 10: Bad configuration option: usekeychain. I think UseKeychain option is specific to macOS, but it isn't recognised in Linux.

Yes the UseKeychain option will be removed for Linux/Windows. Thank you for pointing that.

2 - after fixing the first issue with UseKeychain I was getting a different error: /bin/bash: .ssh/authorized_keys: No such file or directory when I was running ssh gadi "cat >> .ssh/authorized_keys <<< '$(cat ~/.ssh/id_gadi.pub)'".

The first error you got (/bin/bash: .ssh/authorized_keys: No such file or directory) and the fact that you did not get the error with your command (in which you created the .ssh directory) makes me think this issue is caused by the lack of the .ssh directory on Gadi (when you first issued the command).

But when I was doing a cat .ssh/authorized_keys it showed a key.

You were executing that command on Gadi or on your local machine? It seems strange to me that you got a "no such file or directory" for .ssh/authorized_keys but right after you could cat .ssh/authorized_keys without issues.

leonardolaiolo commented 2 months ago

You were executing that command on Gadi or on your local machine? It seems strange to me that you got a "no such file or directory" for .ssh/authorized_keys but right after you could cat .ssh/authorized_keys without issues.

Yes, I think you're correct - Indeed I was running the command in my local machine and the issue must be caused by the lack of the .ssh directory on Gadi.

atteggiani commented 2 months ago

737 solves this issue.

It will be reviewed and merged soon.

Thank you @leonardolaiolo for your contribution!