Is there a way to change default ssh connect port?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I have a lot of servers that I changed my port to 2222.
Can I change on my computer the default port for ssh command? Instead of 22 I want to use 2222 as default.
For instance, instead of using ssh root@ip -p 2222
I want to use ssh root@ip only.
And when I need to use port 22 I type ssh root@ip -p 22
ssh
add a comment |Â
up vote
1
down vote
favorite
I have a lot of servers that I changed my port to 2222.
Can I change on my computer the default port for ssh command? Instead of 22 I want to use 2222 as default.
For instance, instead of using ssh root@ip -p 2222
I want to use ssh root@ip only.
And when I need to use port 22 I type ssh root@ip -p 22
ssh
1
You can configure a port number per host in /etc/ssh/ssh_config.
â muclux
Jan 31 at 19:21
. . . or per user via your~/.ssh/config
file - similar to here Permanently store addresses when using SSH
â steeldriver
Jan 31 at 19:26
1
...or in your~/.bashrc
:alias ssh="ssh -p 2222 "
â waltinator
Jan 31 at 21:17
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a lot of servers that I changed my port to 2222.
Can I change on my computer the default port for ssh command? Instead of 22 I want to use 2222 as default.
For instance, instead of using ssh root@ip -p 2222
I want to use ssh root@ip only.
And when I need to use port 22 I type ssh root@ip -p 22
ssh
I have a lot of servers that I changed my port to 2222.
Can I change on my computer the default port for ssh command? Instead of 22 I want to use 2222 as default.
For instance, instead of using ssh root@ip -p 2222
I want to use ssh root@ip only.
And when I need to use port 22 I type ssh root@ip -p 22
ssh
ssh
asked Jan 31 at 19:16
![](https://i.stack.imgur.com/J6E6P.jpg?s=32&g=1)
![](https://i.stack.imgur.com/J6E6P.jpg?s=32&g=1)
Lucas César
487
487
1
You can configure a port number per host in /etc/ssh/ssh_config.
â muclux
Jan 31 at 19:21
. . . or per user via your~/.ssh/config
file - similar to here Permanently store addresses when using SSH
â steeldriver
Jan 31 at 19:26
1
...or in your~/.bashrc
:alias ssh="ssh -p 2222 "
â waltinator
Jan 31 at 21:17
add a comment |Â
1
You can configure a port number per host in /etc/ssh/ssh_config.
â muclux
Jan 31 at 19:21
. . . or per user via your~/.ssh/config
file - similar to here Permanently store addresses when using SSH
â steeldriver
Jan 31 at 19:26
1
...or in your~/.bashrc
:alias ssh="ssh -p 2222 "
â waltinator
Jan 31 at 21:17
1
1
You can configure a port number per host in /etc/ssh/ssh_config.
â muclux
Jan 31 at 19:21
You can configure a port number per host in /etc/ssh/ssh_config.
â muclux
Jan 31 at 19:21
. . . or per user via your
~/.ssh/config
file - similar to here Permanently store addresses when using SSHâ steeldriver
Jan 31 at 19:26
. . . or per user via your
~/.ssh/config
file - similar to here Permanently store addresses when using SSHâ steeldriver
Jan 31 at 19:26
1
1
...or in your
~/.bashrc
: alias ssh="ssh -p 2222 "
â waltinator
Jan 31 at 21:17
...or in your
~/.bashrc
: alias ssh="ssh -p 2222 "
â waltinator
Jan 31 at 21:17
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Use your favorite editor to modify ~/.ssh/config
nano ~/.ssh/config
and enter
Host *
User root
Port 2222
this would mean, by default, if you tried
ssh remote-host.com
SSH would actually do this
ssh -p 2222 root@remote-host.com
you can, of course, also specify this per host with a special username
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
these settings can also co-exist
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
Host *
User root
Port 2222
See also here for some more ideas.
That's what I was looking for! Thanks alot.
â Lucas César
Feb 1 at 13:27
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Use your favorite editor to modify ~/.ssh/config
nano ~/.ssh/config
and enter
Host *
User root
Port 2222
this would mean, by default, if you tried
ssh remote-host.com
SSH would actually do this
ssh -p 2222 root@remote-host.com
you can, of course, also specify this per host with a special username
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
these settings can also co-exist
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
Host *
User root
Port 2222
See also here for some more ideas.
That's what I was looking for! Thanks alot.
â Lucas César
Feb 1 at 13:27
add a comment |Â
up vote
3
down vote
accepted
Use your favorite editor to modify ~/.ssh/config
nano ~/.ssh/config
and enter
Host *
User root
Port 2222
this would mean, by default, if you tried
ssh remote-host.com
SSH would actually do this
ssh -p 2222 root@remote-host.com
you can, of course, also specify this per host with a special username
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
these settings can also co-exist
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
Host *
User root
Port 2222
See also here for some more ideas.
That's what I was looking for! Thanks alot.
â Lucas César
Feb 1 at 13:27
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Use your favorite editor to modify ~/.ssh/config
nano ~/.ssh/config
and enter
Host *
User root
Port 2222
this would mean, by default, if you tried
ssh remote-host.com
SSH would actually do this
ssh -p 2222 root@remote-host.com
you can, of course, also specify this per host with a special username
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
these settings can also co-exist
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
Host *
User root
Port 2222
See also here for some more ideas.
Use your favorite editor to modify ~/.ssh/config
nano ~/.ssh/config
and enter
Host *
User root
Port 2222
this would mean, by default, if you tried
ssh remote-host.com
SSH would actually do this
ssh -p 2222 root@remote-host.com
you can, of course, also specify this per host with a special username
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
these settings can also co-exist
Host remote-host1 remote-host2 remote-host3
User jackvanier
Port 2222
Host *
User root
Port 2222
See also here for some more ideas.
edited Jan 31 at 20:59
answered Jan 31 at 20:46
Robert Riedl
2,740623
2,740623
That's what I was looking for! Thanks alot.
â Lucas César
Feb 1 at 13:27
add a comment |Â
That's what I was looking for! Thanks alot.
â Lucas César
Feb 1 at 13:27
That's what I was looking for! Thanks alot.
â Lucas César
Feb 1 at 13:27
That's what I was looking for! Thanks alot.
â Lucas César
Feb 1 at 13:27
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1001830%2fis-there-a-way-to-change-default-ssh-connect-port%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You can configure a port number per host in /etc/ssh/ssh_config.
â muclux
Jan 31 at 19:21
. . . or per user via your
~/.ssh/config
file - similar to here Permanently store addresses when using SSHâ steeldriver
Jan 31 at 19:26
1
...or in your
~/.bashrc
:alias ssh="ssh -p 2222 "
â waltinator
Jan 31 at 21:17