I'm using a config file for my OpenSSH client instead of defining options in command line whenever needed, sample from my config file:
$ cat ~/.ssh/config
---- TOP PARTS REDACTED HERE ----
Host hmnw
Hostname hmnw.mydomain.com
User myname
Port 60022
IdentityFile ~/.ssh/id_rsa
When I try to ssh to this host:
$ ssh hmnw
It doesn't work.
But when I do
$ ssh -p 60022 hmnw
It goes through.
Out of curiosity, I did strace
on this process:
$ ssh hmnw&
$ sudo strace -p $!
connect(3, {sa_family=AF_INET, sin_port=htons(22), sin_addr=inet_addr("XX.XX.XX.XX")}, 16
I understand it is trying to connect to default SSH port 22.
Note: Changed my actual hostname and IP address above.
What am I doing wrong?
My ssh version
$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
Adding this after @muru's suggestion
$ ssh -vvvv hmnw
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/myname/.ssh/config
debug1: /home/myname/.ssh/config line 2: Applying options for *
debug1: /home/myname/.ssh/config line 21: Applying options for hmnw
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "hmnw.mydomain.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to hmnw.mydomain.com [xx.xx.xx.xx] port 22.
ssh -v hmnv
please.ssh -p hmnw
.