# Change the default SSH port

**URL:** <https://forums.suse.com/t/change-the-default-ssh-port/7220>\
**Category:** Rancher 1.x\
**Created:** [August 30, 2017, 1:24pm UTC](https://forums.suse.com/t/change-the-default-ssh-port/7220 "2017-08-30T13:24:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![outeredge](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/outeredge/32/2761_2.png) [@outeredge](https://forums.suse.com/u/outeredge)\
**Post date:** [August 30, 2017, 1:24pm UTC](https://forums.suse.com/t/change-the-default-ssh-port/7220/1 "2017-08-30T13:24:08Z")

</div>

We currently deploy our EC2 hosts on RancherOS via Rancher.

Some of our services run on port 22 (git server for example) which means we have no way to SSH into the host without stopping the git service.

Is there anyway we can control the SSH port and still use Rancher to launch the host? If not, is this something we can do after the host has booted (i.e. modify a configuration file somewhere).

Thanks!

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [August 31, 2017, 12:58am UTC](https://forums.suse.com/t/change-the-default-ssh-port/7220/2 "2017-08-31T00:58:21Z")

</div>

I imagine you can do sed replace on the sshd config in the startup script, but changing it is not going to play well with docker-machine (which Add Host in Rancher uses)… 22 is [hardcoded](https://github.com/docker/machine/blob/master/drivers/amazonec2/amazonec2.go#L356) in the driver.

---

<div class="post-metadata">

**Author:** ![outeredge](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/outeredge/32/2761_2.png) [@outeredge](https://forums.suse.com/u/outeredge)\
**Post date:** [August 31, 2017, 9:09am UTC](https://forums.suse.com/t/change-the-default-ssh-port/7220/3 "2017-08-31T09:09:12Z")

</div>

Can we modify the ssh config post deploy without causing problems (bearing  
in mind that 22 on the host is taken over by git anyway)?

If so, what is the correct ssh config file on RancherOS?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [August 31, 2017, 5:52pm UTC](https://forums.suse.com/t/change-the-default-ssh-port/7220/4 "2017-08-31T17:52:46Z")

</div>

Standard `/etc/ssh/sshd_config`

---

<div class="post-metadata">

**Author:** ![outeredge](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/outeredge/32/2761_2.png) [@outeredge](https://forums.suse.com/u/outeredge)\
**Post date:** [September 1, 2017, 5:30pm UTC](https://forums.suse.com/t/change-the-default-ssh-port/7220/5 "2017-09-01T17:30:10Z")

</div>

Thanks although the sshd\_config file seems to get reverted after a reboot. How can we persist the change?
