69

I'm trying to connect to my Debian Google Compute Engine server through PuTTy (I've tried other alternatives too) but when I do I get the error "Disconnected: No supported authentication methods available (server sent: publickey)

The google server came without a username and password, only a url to automatically login to their own terminal.

19 Answers 19

25

I had PuTTY working and then one day got this error.

Solution: I had revised the folder path name containing my certificates (private keys), and this caused Pageant to lose track of the certificates and so was empty.

Once I re-installed the certificate into Pageant then Putty started working again.

3
  • 4
    It would have been nice for the Compute Engine SDK to mention that you need to launch pageant in the first place. I totally forgot you need to run this application and add the generated SSH key to it.
    – Gili
    Nov 13, 2014 at 19:05
  • 2
    @Gili you don't have to... You can specify the key in PuTTY under Connection->SSH->Auth. You will be prompted for the private key password
    – Basic
    Jul 8, 2015 at 1:19
  • or, just add the private keys to pageant and you are good to go.
    – Andrew
    Jul 18, 2016 at 15:36
21

Turn on Password Authentication

By default, you need to use keys to ssh into your google compute engine machine, but you can turn on password authentication if you do not need that level of security.

Tip: Use the Open in browser window SSH option from your cloud console to gain access to the machine. Then switch to the root user with sudo su - root to make the configuration changes below.

enter image description here

  1. Edit the /etc/ssh/sshd_config file.
  2. Change PasswordAuthentication and ChallengeResponseAuthentication to yes.
  3. Restart ssh /etc/init.d/ssh restart.
7
  • It now asks me for a password while using gcloud? I dont understand which is this. Feb 9, 2015 at 15:10
  • 7
    This NOT a good idea as you increase the likelihood your instance is getting compromised by brute force attacks. Please never use this in production only on a test instance or as a short workaround to get your keys right!
    – Feczo
    Feb 23, 2015 at 0:13
  • 2
    To restart ssh in CentOS 7 you can use $ service sshd restart
    – imbayago
    Jun 7, 2017 at 15:38
  • just for knowledge sake if password auth is enabled what will be the password?
    – Dev G
    Jan 5, 2018 at 19:33
  • @DevG it is usually in the provisioner. For me it is in a .pp file since I use puppet for provisioning. However this should only be used for development and not live since it is hardcoded.
    – ploopploop
    Jan 17, 2018 at 10:43
9

Please follow this guide: https://gist.github.com/feczo/7282a6e00181fde4281b with pictures.

In short:

Using Puttygen, click 'Generate' move the mouse around as instructed and wait

  • Enter your desired username

  • Enter your password

  • Save the private key

Copy the entire content of the 'Public key for pasting into OpenSSH authorized_keys file' window. Make sure to copy every single character from the beginning to the very end!

Go to the Create instances page in the Google Cloud Platform Console and in the advanced options link paste the contents of your public key.

Note the IP address of the instance once it is complete. Open putty, from the left hand menu go to Connection / SSH / Auth and define the key file location which was saved.

From the left hand menu go to Connection / Data and define the same username

  • Enter the IP address of your instance
  • name the connection below saved Sessions as 'GCE' click on 'Save'
  • double click the 'GCE' entry you just created
  • accept the identy of the host

Now login with the password you specified earlier and run sudo su - and you are all set.

1
  • can you please fix the gist link as it appears to be broken... thx
    – vidriduch
    Apr 14, 2016 at 15:18
8

You need to use an SSH key to login to your instance.

The GCE documentation explains the process here.

7

I had the same problem but got it working by changing enable-oslogin from TRUE to FALSE in google cloud.

from:

to: enter image description here

2
  • 4
    I find this puzzling, because the instructions from Google start by saying to set it to TRUE. "To provide your SSH key to the instance, use one of the following methods: (Recommended) Enable OS Login and use IAM roles to provide your public SSH key to the instance through your Google Account or a managed user account."
    – Eddie Rowe
    Apr 7, 2020 at 16:02
  • I don't understand how it could work...
    – Loenix
    Feb 2, 2022 at 10:22
4

I had the same issue and just figured it out !!

Assuming that you already went and created private/public key added your public key on the remote server ... type in [email protected] and THEN go to Connection -> SSH -> Auth and click Browse to locate your private key. After you choose it will populate the input field. After that click OPEN ...

So the important thing here is the order... make sure you first enter parameters for the host and then locate your private key.

3

I got this error because I had forgotten to add my username behind the key in the GCE metadata section. For instance, you are meant to add an entry into the metadata section which looks like this:

sshKeys    username:key

I forgot the username: part and thus when I tried to login with that username, I got the no supported auth methods error.

Or, to turn off the ssh key requirement entirely, check out my other answer.

2

Apparently running sudo chmod -R a+rw on your home folder causes this to happen as well.

2

This problem mainly caused by your connected username not have the access to the shell in GCE. So you use the following steps to solve this issue.

gcloud auth list

If you are using the correct login. please follow the below steps. otherwise use

gcloud auth revoke --all
gcloud auth login [your-iam-user]

and you get the token or it automatically detect the token.

gcloud compute --project "{projectid}" ssh --zone "{zone_name}" "{instance_name}" .

if you dont know this above line click to compute engine-> ssh dropdown arrow-> view google command-> copy that code and use it

Now it update your metadata and it is available in your computer's folder Users->username

~/.ssh/google_compute_engine.ppk
~/.ssh/google_compute_engine.pub

Then you create a new ppk file using puttygen and you give the username, which you want like my_work_space. Then save the publickey and privatekey in a folder.

Next step: Copy the public key data from puttygen and create new ssh key in gcloud metadata

cloud console ->compute engine->metadata->ssh key->add new item->paste the key and save it

and now return your shell commandline tool then enter

sudo chown -R my_work_space /home/my_work_space

now you connect this private key using sftp to anywhere. and it opens the files without showing the permission errors

:) happy hours.

1

If the private key has been generated with ssh-keygen in Linux it needs to be converted with puttygen because Putty does not support openssh keys.

Start puttygen, and click on Conversions - Import key, then click Browse and select the private key generated with openssh, then click on Save private key.

Use your new key to connect.

1

I faced the same issue and solve after several trial and error. In the /etc/ssh/ssh_config, set

  • PubkeyAuthentication yes

  • AuthorizedKeysFile .ssh/authorized_keys

  • PasswordAuthentication no

  • AuthenticationMethods publickey

then, open putty. In the "Saved Sessions", enter the server IP, go through the path Connection->SSH->Auth->Browse on the left panel to search your private key and open it. Last but not least, go back to Session of putty on the left panel and you can see the server IP address is still in the field, "Saved Sessions", then click "Save", which is the critical step. It will let the user login without password any more. Have fun,

1

Download "PuttyGEN" get publickey and privatekey use gcloud SSH edit and paste your publickey located in /home/USER/.ssh/authorized_keys

sudo vim ~/.ssh/authorized_keys

Tap the i key to paste publicKEY. To save, tap Esc, :, w, q, Enter. Edit the /etc/ssh/sshd_config file.

sudo vim /etc/ssh/sshd_config

Change

PasswordAuthentication no [...] ChallengeResponseAuthentication to no. [...] UsePAM no [...] Restart ssh

/etc/init.d/ssh restart.

the rest config your putty as tutorial NB:choose the pageant add keys and start session would be better

1

Electricity went down and got this error. Solution was to double click your .ppk (Putty Private Key) and enter your password.

0

PasswordAuthentication and ChallengeResponseAuthentication default set to NO in rhel7.

Change them to NO and restart sshd.

0

Similar problem - same error message. I got the same message when trying to clone something from bitbucket with ssh. The problem was in my ssh configuration configured in the mercurial.ini: I used the wrong bitbucket username. After I corrected the user name things worked.

0

For me these was my problem, solution from https://unix.stackexchange.com/questions/282908/server-refused-public-key-signature-despite-accepting-key-putty

"Looking at the log /var/log/secure showed that it was just downright refused. I'm somewhat new to centos since I'm mainly a debian kind of guy, so I was unaware of /var/log/secure

After checking this and doing a bit of searching, it turns out PermitRootLogin no needs to be PermitRootLogin without-password if you want to specifically use just keys for root login. That did the trick. Thanks everyone for contributing."

0

I had the same error message and discovered that my mistake was in the username I used with putty. Apparently GCE SSH Keys listing would change your username characters in some of the listing. In my case, the underscore was changed to period. i.e: my_username becomes my.username

I inadvertently copied the wrong username from the listing and got the same error message.

0

The answer provided by Feczo is misleading. The answer and the included link states to use puttygen and enter username. Puttygen does not ask for username.

Answer by Nate worked for me. ie:

  • Go to metadata section and add an entry as metadata: sshKey Value: 'ýourusername':'XXXX'
  • replace ýourúsername'with your user name. Replace 'XXXX' with your public key.
  • click save.
-1

I know this is an old question, but I had the same problem and solved it thanks to this answer.

I use Putty regularly and have never had any problems. I use and have always used public key authentication. Today I could not connect again to my server, without changing any settings.

Then I saw the answer and remembered that I inadvertently ran chmod 777 . in my user's home directory. I connected from somewhere else and simply ran chmod 755 ~. Everything was back to normal instantly, I didn't even have to restart sshd.

I hope I saved some time from someone

3
  • 1
    can we get information about from where exactly you logged in ? somewhere else sounds bit of no information.
    – Zee
    May 24, 2022 at 13:15
  • Where I logged on from doesn't really matter for this answer as the solution is clearly stated as "dont make your home dir chmod 777".
    – LuizLoyola
    May 26, 2022 at 14:57
  • @Zee but I logged in from the Google Cloud web interface, that little "SSH" button on the instance list
    – LuizLoyola
    May 26, 2022 at 14:59

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