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
fileHost 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,
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 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