I frequently use
scp -r id@remoteserver_ip:/Data_folder/
to download data a folder from a remote supercom server.
Having to write the same every time is rather tiresome.
Does anybody know easy to use this command using alias? Consider that Data_folder will be changed every time.
You should consider setting up ssh config:
Host myServer
HostName remoteserver_ip
User id
And perhaps add a identity file as well to avoid having to type password:
Host myServer
...
IdentityFile ~/.ssh/my_id
Now you can write:
scp -r myServer:/something
Of cause you can - as suggested by other answers - add a function to your ~/.bashrc:
my_scp() {
scp -r myServer:"$1"
}
And then call:
my_scp /something
Alias can't replace a part of a word. You can create a function, though:
myscp () {
scp -r id@remoteserver_ip:/"$1"/
}
Then, just call myscp Data_folder.
Also, scp (at least on my system) needs the destination folder, too. You can add . as then next parameter to the command in the function, or use "$2" and specify it on the command line when running the function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With