2

I am connecting via ssh to a remote server, as follows:

ssh user@128.x.x.x

The process works fine as I have the password to get into the server I need to work with.

I wanted to set a name to the IP address, as I would like to make the process smoother and avoid typing and remembering the server IP every single time.

I have edited the /etc/hosts file adding the IP and linking to a new name, as follows (second row):

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
::1             localhost
128.x.x.x       newname

I have flushed the DNS cache with:

sudo killall -HUP mDNSResponder; sleep 2; echo macOS DNS Cache Reset | say

And yet, when calling the ssh server from the terminal via this command:

ssh user@newname

The command does not work and shows the following error message:

ssh: connect to host newname port 22: Operation timed out

Any suggestion is welcomed thanks!

  • 1
    Odd. What happens if you run ping newname? Also, have you tried just closing and reopening a terminal window? – JakeGould Sep 6 at 23:01
  • 1
    Consider using a Host entry in your ~/.ssh/config file instead. – MZB Sep 7 at 0:18
  • Hi everyone and thanks for the answers @JackGould I have tried closing and reopening the terminal, nothing changed so far. If I run ping newname the following lines appear: PING newname (128.x.x.x): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 ... @MZB I have deleted the newname lines from /etc/hosts, and I have created/edited a ~/.ssh/config file as follows: Host newname HostName 128.x.x.x User user I have flushed the cache, closed/reopened the terminal, still not working. Maybe a port or id_rsa (not using either of them)? – uomoz Sep 9 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.