Home > Net >  Force user to login with ssh key file
Force user to login with ssh key file

Time:12-15

I have disabled the passwordAuthentication in ssh and I can only access ssh using the .pem key file. But I can log in to ssh using

   ssh 'user@host'

I need to restrict a valid user login without the .pem key file or not able to login using the above command. Kindly help me to solve this. Thanks in advance.

CodePudding user response:

if you have already disabled the passwordAuthetication, you can only connect via an authorized key. When you "ssh user@host" without the "-i path/key" it will try every possible method until it finds one that succeeds.

you probably have your pem file inside your .ssh directory, the system will try every key files stored there until one match or there aren't any keys left to try (in this case it will output an error)

tl:dr if your key file is inside your .ssh dir, it will, automatically, try to use it

  • Related