changing ssh port caused refuse to connect

Kukula Mula asked:

these are the steps I followed to change the default ssh port

  1. login to compute engine instance using gcutil ssh
  2. cd /etc/ssh
  3. sudo nano sshd_config –> changed the port to some number lets say for the example: 1111
  4. saved and exit
  5. sudo service ssh restart —> [ ok ] Restarting OpenBSD Secure Shell server: sshd.
  6. open a new terminal and repeated step 1 —> ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused —-> the change succeded
  7. went to my GCE console and added a firewall with the tcp:1111
  8. tried to connect again with gcutil ssh —> ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused
    I’m not following why after enabling the port 1111 on the GCE gcutil ssh still tries to connect on port 22

    INFO: Running command line: ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/MyUser/.ssh/google_compute_engine -A -p 22 MyUser@xxx.xxx.xxx.xxx —

what am i missing? should I download my ssh key again after changing the port? and if so how do i do that?

My answer:


The documentation clearly states how to provide an alternate ssh port for gcutil ssh.

  --ssh_port: TCP port to connect to
    (default: '22')
    (an integer)

in your case:

gcutil ssh --ssh_port=1111 <instance name>

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.