I'm attempting to ssh into a server from terminal on MAC. It was working a few days ago but just stopped today.

When I enter ssh username@server -i .ssh/file

I get -bash: ssh username@server -i: command not found

whereis ssh yields /usr/bin/ssh

echo $PATH gives me a weird looking path /Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

I tried to set PATH to /usr/bin with export PATH=/usr/bin and it appears to set it but on restart it resets to the above path.

SSH Config when running sudo nano /etc/ssh/ssh_config

  GNU nano 2.0.6           File: /etc/ssh/ssh_config                            

#       $OpenBSD: ssh_config,v 1.34 2019/02/04 02:39:42 dtucker Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

What finally worked for me is the following command: /usr/local/Cellar/openssh/8.6p1/bin/ssh username@server -i .ssh/file

  • Are you sure there isn’t some incorrect quoting there? Basically the only way you could get the first message is by using "ssh username@server -i" .ssh/file.
    – Daniel B
    Jun 17, 2021 at 12:21
  • I'm running command as shown without any quotes. Same with the last command that worked.
    – Hyetigran
    Jun 17, 2021 at 12:24
  • -bash: ssh username@server -i: command not found Somehow bash is interpreting the entire string "ssh username@server -i" as the name of the command to run. There are a couple of things that could cause this, but they mostly would involve you running the command in some other way than by just typing it in.
    – Kenster
    Jun 17, 2021 at 12:47
  • 1
    Did you paste the command? Or did you type it? If pasted, the chances are you copied from a source where (at least some) "spaces" are not regular ASCII spaces. Jun 17, 2021 at 14:16
  • @KamilMaciorowski I typed in the command instead of pasting it in and it worked. I had no freakin clue. Thanks a million!
    – Hyetigran
    Jun 17, 2021 at 14:36


You must log in to answer this question.

Browse other questions tagged .