dib-lab / farm-notes

notes on the farm cluster
16 stars 9 forks source link

how to debug ssh login issues on farm #62

Open ctb opened 1 year ago

ctb commented 1 year ago

so! you can't log into farm with ssh because it's asking you for a password and you don't have one! what next??

This is most likely being caused by one of three problems:

  1. your account is not yet created; other than waiting and trying again, and/or confirming with the sysadmin, you can also ask someone who already has an account on the system to look for your account by doing grep -i username /etc/passwd.
  2. your ssh private key is not being found. This may be because it is not named the right thing on your system, or it's in the wrong location.
  3. your ssh public key on the system does not match the private key you are using. This is often because you created the account with the wrong public key, or an old public key is still installed on your farm account.

The steps below will help diagnose

first: add -v to your ssh command line and inspect the output

Instead of doing ssh ctbrown@farm.cse.ucdavis.edu do ssh -v ctbrown@farm.cse.ucdavis.edu.

Inspect the output and check that it's finding your private key properly. You're looking for at least one line that says something like:

debug1: Will attempt key: /Users/t/.ssh/id_rsa RSA SHA256:bLtuYpJrIqtClNRSo2dejK+tbMFhkyaNtx5GYWfI2cc
...
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/t/.ssh/id_rsa RSA SHA256:bLtuYpJrIqtClNRSo2dejK+tbMFhkyaNtx5GYWfI2cc

If you continue to have problems logging in, the output of ssh -v is important information to send to the farm helpdesk.

second: try using -v -i <keyfile> to explicitly specify the private key file

If it's not finding the key file above (or even if you think it is), try specifying the key file explicitly:

ssh -v -i /path/to/id_rsa ctbrown@farm.cse.ucdavis.edu

This will (in theory!) make sure that the right key file is being used. (Inspect the output to make sure it IS using it, of course.)

third: regenerate public key & update your account with the (correct) public key

Sometimes your public key on your account may not match the private key you're using to login. There is no way to recover a private key if you've lost track of it, but it's easy to regenerate a public key if you have a private key!

Use the following command to print out a new public key:

ssh-keygen -y -f /path/to/id_rsa

Then, go to https://hippo.ucdavis.edu/Farm/create and paste the output of this command into hippo for the public key.

Note, this will require someone else (the account manager for your lab's buy-in) to approve the hippo request, so it may take a little while.

alternative: generate a new private key

If you've completely lost your private key, or want to just start from scratch (and then update your account as above), do the following to generate a new public/private key pair:

ssh-keygen

Note that if you overwrite your old private key, there is no way to recover it!

appendix: setting up your ssh config

If you put something like this in your ~/.ssh/config file on your laptop/desktop, you can then just type ssh farm to log in.

Host farm
    HostName farm.cse.ucdavis.edu
    User ctbrown