英文:
How to SSH into Linux Server executing Alias with Parameter using /.ssh/config file from PowerShell (Windows Terminal)
问题
I can not ssh into server using my .ssh/config file through Alias from my PowerShell Profile file and run some couple of commands.
I already have working my .ssh/config
file to go into my linux server (With Key)
.ssh/config
file
Host ubu
Port 2200
HostName 192.168.1.197
User julio
Now I want to ssh into server using Alias from my PowerShell Profile file and run some updates commands
sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade && sudo apt autoremove -y && sudo apt autoclean
I try this unsuccesfully,
- PowerShell Profile File
Function ubuFullUpdate {ssh ubu; sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade && sudo apt autoremove -y && sudo apt autoclean}
Set-Alias -Name ubu -Value ubuFullUpdate
Just go into server (.ssh/config
work fine) and all next commands fail.
Function ubuFullUpdate {ssh -t -p 2200 julio@192.168.1.197 sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade && sudo apt autoremove -y && sudo apt autoclean}
Set-Alias -Name ubu -Value ubuFullUpdate
Go into server but just work sudo apt update
and the following commands fail and flag error.
Normal error message in both cases
> The term 'sudo' is not recognized as a name of a cmdlet, function, script file, or executable program. Check
> the spelling of the name, or if a path was included, verify that the path is correct and try again.
>
I'm sure it's not sudo itself the failure, it's what follows from that point and being able to execute several consecutive commands
Happy Fixing!!
英文:
I can not ssh into server using my .ssh/config file through Alias from my PowerShell Profile file and run some couple of commands.
I already have working my .ssh/config
file to go into my linux server (With Key)
.ssh/config
file
Host ubu
Port 2200
HostName 192.168.1.197
User julio
Now I want to ssh into server using Alias from my PowerShell Profile file and run some updates commands
sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade && sudo apt autoremove -y && sudo apt autoclean
I try this unsuccesfully,
- PowerShell Profile File
Function ubuFullUpdate {ssh ubu; sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade && sudo apt autoremove -y && sudo apt autoclean}
Set-Alias -Name ubu -Value ubuFullUpdate
Just go into server (.ssh/config
work fine) and all next commands fail.
Function ubuFullUpdate {ssh -t -p 2200 julio@192.168.1.197 sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade && sudo apt autoremove -y && sudo apt autoclean}
Set-Alias -Name ubu -Value ubuFullUpdate
Go into server but just work sudo apt update
and the following commands fail and flag error.
Normal error message in both cases
> The term 'sudo' is not recognized as a name of a cmdlet, function, script file, or executable program. Check
> the spelling of the name, or if a path was included, verify that the path is correct and try again.
>
I'm sure it's not sudo itself the failure, it's what follows from that point and being able to execute several consecutive commands
Happy Fixing!!
答案1
得分: 0
I finally was able to find one easy solution (because like all in IT has more than one way to do it)
> 不需要 .ssh/config 文件
Function ubuFullUpdate {ssh -t -p 2200 <USERNAME>@<SERVERIPADRRESS> 'sudo apt update; sudo apt upgrade -y; sudo apt dist-upgrade; sudo apt autoremove -y; sudo apt autoclean'}
Set-Alias -Name ubu -Value ubuFullUpdate
ubuFullUpdate = 任何函数名称
ubu= 任何别名名称
英文:
I finally was able to find one easy solution (because like all in IT has more than one way to do it)
> No .ssh/config file needed
Function ubuFullUpdate {ssh -t -p 2200 <USERNAME>@<SERVERIPADRRESS> 'sudo apt update; sudo apt upgrade -y; sudo apt dist-upgrade; sudo apt autoremove -y; sudo apt autoclean'}
Set-Alias -Name ubu -Value ubuFullUpdate
ubuFullUpdate = any function name
ubu= any alias name
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论