How to disable strict host key checking

By Angus Published 14 April 2025 Updated 28 January 2026 2 min read

Your SSH client normally checks the identity of every server you connect to. Sometimes that gets in the way. Automated scripts can’t handle interactive prompts and in testing environments where host keys change constantly it makes verification pointless. You need the connection to just work.

Skip the check for one connection

Need to bypass it just once? Add this flag:

ssh -o StrictHostKeyChecking=no user@remote-host

SSH connects without asking. No prompt, no stored key.

Turn it off permanently

If you’re repeatedly connecting to the same systems, configure your SSH client instead of adding flags every time.

Open your SSH config file:

nano ~/.ssh/config

The file might not exist yet. The command creates it.

For all connections

Add this to disable checking everywhere:

Host *
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Every SSH connection from your machine skips verification. The UserKnownHostsFile /dev/null bit stops SSH from storing any host keys.

For specific hosts only

Better approach:

Host 192.168.1.10
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Host dev-server.example.com
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Only those hosts bypass the check. Everything else keeps the default security.

Lock down the config file permissions:

chmod 600 ~/.ssh/config

When you’d actually do this

Host key checking exists to catch man-in-the-middle attacks. You’re removing that protection.

Internal networks where you trust the infrastructure? Fine. Testing systems where host keys change constantly? Makes sense. CI/CD pipelines that need to connect without human intervention? Reasonable use case.

Don’t disable it on production systems connected to untrusted networks. If you’re managing production SSH access at scale, look at SSH certificate authentication instead.

Accept new hosts but verify known ones

Want something between full verification and none at all?

Host *
    StrictHostKeyChecking accept-new

This accepts new host keys automatically but still verifies servers you’ve connected to before. First connection goes through without a prompt, subsequent connections get checked.

Comes in handy if you’re adding SSH keys to GitHub or mounting remote file systems via SSH where you know the infrastructure but don’t want the initial prompt.

Need more power?

Get scalable resources with our VPS hosting with root access and optional software.

Get VPS Hosting

Starting something new?

Perfect for websites and small businesses unlimited bandwidth with cPanel hosting.

Get cPanel Hosting