How to save ssh-keyscan result with the port to .ssh/known_hosts

33

This is usually not needed since current ssh-keyscan versions will add the port for you. Older versions did not do that. You could post-process the line with sed like this:

ssh-keyscan -p NNN -t rsa GITHOST | sed -E 's/^([^ \[]+) (.*)$/[\1]:NNN \2/'

The output of ssh-keyscan is piped into sed that will use a substitute regexp to transform the output of ssh-keyscan to include the port.

This will result in:

[GITHOST]:NNN ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCZw....

Update: I refined the regexp above to play nice with ssh-keyscan output in already correct format.

Share:
33

Related videos on Youtube

Ravi Singh Chauhan 36
Author by

Ravi Singh Chauhan 36

Updated on September 18, 2022

Comments

  • Ravi Singh Chauhan 36
    Ravi Singh Chauhan 36 almost 2 years

    Hello developers I am Ravi Singh Chauhan I get error taht says:- NullReferenceException: Object reference not set to an instance of an object Crosshair.OnGUI () (at Assets/Scripts/Combat/Crosshair.cs:22) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

    My Crosshair script is here:- https://i.stack.imgur.com/hD2NE.jpg

    Please help me to solve this error

    • Tim S.
      Tim S. almost 9 years
      When you say you added it to known_hosts, what exactly did you add? How does the known_hosts file look?
    • Jakuje
      Jakuje almost 9 years
      what system are you using? Do you have HashKnownHosts=yes? If so, you will need to hash your hosts fin that file using ssh-keygen -H after that.