Receiving error when trying to use ~/.ssh/config “ssh: Could not resolve hostname”

I am losing my mind because of this. I have scurried the internet for a solution, but no solution is working for me! I am trying to create a bastion server with a public AWS EC2 instance that will connect to a private EC2 instance.

Below is my ~/.ssh/config file:

Host bastion Hostname <instanceIP> User ec2-user IdentityFile <keypairPath> ProxyCommand none Host private Hostname <privateIP> User ec2-user IdentityFile <keypairPath> ProxyCommand ssh bastion -W %h:%p

When I attempt to run ssh bastion I receive this error:

ssh: Could not resolve hostname bastion: Name or service not known

I can connect with ssh -F config bastion with root (but not with local user), but I do not want to put that argument every time since I have seen that the -F is not required.

I also am not able to connect with ssh -F config private as root. The error states:

ssh: Could not resolve hostname bastion: Name or service not known ssh_exchange_identification: Connection closed by remote host

I changed up the last line in the /.ssh/config file to ProxyCommand ssh -F config bastion -W %h:%p, but that brings back this error:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic). Killed by signal 1

What am I doing wrong with my config file, and how can I ssh with the local profile and not root?

How to setup .ssh/config for git on non-standard port

I know something similar has been asked multiple times, but I wasn’t able to find the right solution for my case.

I have a custom git repository accessible via ssh on a non-standard port; URL is something like:

git clone ssh:// 

private key for that repo is in ~/.ssh/myname.prv.

I am trying to get access the repo without passwords, but I’m failing.

My current ~/.ssh/config has a stanza:

Host git     HostName     Port 12345     User myname     IdentityFile ~/.ssh/myname.prv 

… but git still asks for a PW.

What am I missing?

Note: both server and client are fairly recent Linux machines and I’m working at the command line, if it matters.