Is there a way to change default ssh connect port?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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










share|improve this question

















  • 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














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










share|improve this question

















  • 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












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










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 31 at 19:16









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












  • 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










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.






share|improve this answer






















  • That's what I was looking for! Thanks alot.
    – Lucas César
    Feb 1 at 13:27











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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.






share|improve this answer






















  • That's what I was looking for! Thanks alot.
    – Lucas César
    Feb 1 at 13:27















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.






share|improve this answer






















  • That's what I was looking for! Thanks alot.
    – Lucas César
    Feb 1 at 13:27













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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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


















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

Which professions warranted travel in Medieval times?

How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

Trouble downloading packages list due to a “Hash sum mismatch” error