Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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 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 --

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

share|improve this question

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>
share|improve this answer
why waist time writing an answer if you don't supply any useful data??? as mentioned above i DID change the ssh port but when trying to reconnect it fails so obviously the problem lies in the client side, but I don't know where to configure the ssh command to run with different port i can always connect with the full command: ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/Kukula/.ssh/google_compute_engine -A -p 1111 but that is not what i'm asking so if you do know the answer and willing to share i'd appreciate it – Kukula Mula Feb 17 '14 at 8:42
Your question never mentioned that you did this - and it still doesn't. If you actually did, then you need to edit your question. – Michael Hampton Feb 17 '14 at 14:27
I suggest you first read what i wrote step 6 states : The change succeeded, before being condescending! – Kukula Mula Feb 18 '14 at 11:17
@KukulaMula No one is being condescending here. We are trying to help you. AGAIN, you need to edit your question. – Michael Hampton Feb 18 '14 at 12:58

Faced the same problem, still don't know which file to change inorder for the standart gcutil ssh <machine_name> to call the new port in your case 1111, @Michael Hampton answer was correct, but he didn't wrapped it within the entire command which confused you so try the following command i believe it will work and you'll be able to connect with your instance

gcutil ssh --ssh_port 1111 <machine_name>

share|improve this answer

ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/MyUser/.ssh/google_compute_engine -A -p 22

That "-p 22" tells the ssh command to try to connect to a server on port 22. Change the 22 to the port you have your server running on and you should be good to go.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.