I'm aware about how to check if a host exists in known_hosts

ssh-keygen -F github.com

I need to do it in a script. Namely, if a host exists - do nothing, otherwise - add it. How would I do it?

  • What's wrong with putting that line in the script? – roaima Feb 20 at 14:05
  • 3
    In that case I'm sorry but I don't understand why you're asking the question – roaima Feb 20 at 14:19
  • 3
    If the line you've shown does what you want, put it into your script. If it doesn't do what you want, explain that please. – roaima Feb 20 at 15:01
  • 1
    He means, "please write the if test for me, so that I don't have to." – Marc Wilson Feb 20 at 15:43
  • 3
    @michika usually, if someone is having trouble understanding your question, it isn't because they need to read it again but because you haven't made the question clear. So instead of suggesting roaima rereads, why don't you instead edit your question and clarify what you are asking. You already give a command that seems to do what you need, so it is hard to understand what else you want. What part of this is giving you trouble? What do you know how to do and what do you need help with? – terdon Feb 20 at 15:52

Your Answer

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

Browse other questions tagged or ask your own question.