- 1 year ago
How to SSH into Linux Server executing Alias with Parameter using /.ssh/config file from PowerShell (Windows Terminal)
To SSH into a Linux Server executing an Alias with a Parameter using the /.ssh/config file from PowerShell (Windows Terminal), you can follow these steps:
Open the PowerShell (Windows Terminal) application on your Windows machine.
Navigate to your home directory using the following command:
bashcd ~
Create a new file called
config
in the.ssh
directory using the following command:mathematicaNew-Item -ItemType File -Path ~/.ssh/config
Open the
config
file using a text editor of your choice.Add the following lines to the file:
javascriptHost myserver
Hostname <IP Address or Hostname>
User <Username>
Port <Port Number>
IdentityFile ~/.ssh/<Private Key File>
Host myalias
Hostname myserver
RequestTTY yes
RemoteCommand 'my_alias_command -p parameter'
Replace
<IP Address or Hostname>
with the IP address or hostname of your Linux server,<Username>
with your server username,<Port Number>
with the port number used for SSH, and<Private Key File>
with the filename of your private key file.Replace
myserver
with the name you want to give to your server, andmyalias
with the name you want to give to your alias.Replace
my_alias_command -p parameter
with the actual command you want to run on your server, followed by any parameters.Save and close the
config
file.Run the following command to SSH into your server using the alias:
ssh myalias
This will execute the command specified in the
RemoteCommand
line in theconfig
file.If prompted, enter the passphrase for your private key.
If successful, you should be logged in to your Linux server and the specified command should have executed.