is there any way to hide port number while login with ssh that need custom port number

前端 未结 2 498
逝去的感伤
逝去的感伤 2021-01-24 05:52

I want to login to my server that has custom ssh port like -

ssh -p  root@example.com

Now I want such short comman

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-24 05:54

    You can't do exactly that, but you can do something very similar. In your .bashrc add this line:

    export myshortcode='-p  root@example.com'
    

    Now you execute the command loke this:

    ssh $myshortcode
    

    Or you add an alias like

    alias ssh_port='ssh -p  root@example.com'
    

提交回复
热议问题