Skip to main content
jefazo92
Explorer II
November 4, 2024
Solved

Can an SSH connection to a Fortigate be stablished with a hostname (not an IP address)?

  • November 4, 2024
  • 2 replies
  • 1544 views

Hi, I want to connect to my Fortigate using its hostname via SSH with PuTTY. However, the documentation only mentions establishing a session via IP address and whenever I try to connect by writing the hostname in the Hostname (or IP address) field, it gives me the error host does not exist. Session is established successfully without any errors if I use the the MGMT port's IP address instead.

Best answer by Hatibi

Yes it should work. It is probably a DNS issue.

Can you ping the Fortigate by hostname through cmd?

Try adding Hostname to IP relation in your windows hosts file at C:\Windows\System32\drivers\etc\hosts.

2 replies

Hatibi
Staff & Editor
HatibiAnswer
Staff & Editor
November 4, 2024

Yes it should work. It is probably a DNS issue.

Can you ping the Fortigate by hostname through cmd?

Try adding Hostname to IP relation in your windows hosts file at C:\Windows\System32\drivers\etc\hosts.

jefazo92
jefazo92Author
Explorer II
November 4, 2024

@Hatibi It worked by adding the hostname to the hosts file as you mentioned above! I was able to both ping and SSH into my device using the hostname. There was no need for me to enable DNS Server on the MGMT interface. Thank you very much!

Hatibi
Staff & Editor
Staff & Editor
November 4, 2024

In this case you simply need to make sure that your DNS server, configured for your local host (PC), is able to resolve the Hostname to an IP. 

No need to enable DNS in MGMT port.

 

Try the following:

 

In your PC edit the "hosts.txt" file located in C:\Windows\System32\drivers\etc\  and add an entry for the FortiGate hostname.

The Hosts file acts as a local DNS cache/resolver.

Example:

10.10.10.1 FortiGateLab   <---- In your case replace "FortiGateLab" with the hostname you have.

 

This external guide explains hosts file is: https://en.wikiversity.org/wiki/Hosts_file/Edit#:~:text=The%20hosts%20file%20is%20a,be%20modified%20by%20an%20administrator.