0

So I have been trying to build ssh connections between google cluster container containing 1 master node and 2 worker nodes. I have used ssh-keygen to generate key pairs for all three nodes, send the two private keys of the 2 workers to the master node and into the .ssh/autherized_keys file. Then I shared this file with the two worker nodes too.

This approach makes successful ssh connections right after. The ssh connection was fine and I could also use scp to send over files. Yet as in later stages as I logout and re-login into the VMs, the ssh connection became very unstable, as sometimes it returns connection failure error : Permission denied (publickey), while sometimes the connection could be again triggered.

Anyone knows what the problem is? Thanks in advance!

  • 1
    More info is needed to properly diagnose this. What's the output of ssh -v thehostnameyouwanttoconnectto.com ? – Jarmund May 24 '15 at 18:54
0

If it was working at one point and isn't now, do:

# Adjust paths as necessary. May need to add sudo if you're not running it as root.
chmod 700 ~/.ssh && chmod 600 ~/.ssh/* && chmod 644 ~/.ssh/authorized_keys

If still no love, verify contents of authorized_keys, and check the following values in /etc/ssh/sshd_config (or whatever your sshd config file is.) This will disable password auth, and enable ssh only authentication against the system.

RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
UsePAM no # Just my choice.

Secuirty Note: I recommend using a password protected private key when accessing your cloud environment, and only setting this up against a single system, a jump server. From there you can more confidently utilize passwordless ssh authentication to the rest of your environment.

|improve this answer|||||
  • Thanks for the reply! I have checked the sshd_config, and even has further changed to allow empty password (which was set to no). Yet the connection is still not stable. By not stable, it can always connect successfully upon the first logging in, but after a few minutes (even without any interleaving commands), the ssh command then becomes not working (while the same ssh command as one previously executed command works). – bcxuezhe39 May 25 '15 at 15:13
  • ~/.ssh/authorized_keys should never be group or others accessible and should have 600 permissions. – JW0914 Feb 12 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.