SCP shortcut command to known machine

For example you need to deal with different machines, and it takes time to write the IP addresses for each. Can we shorten the writing part?

What you need to do is list the IP addresses with the corressponding name in /etc/hosts file. For example :

xxx.yy.z.kk master
xxx.yy.z.kk slave1
xxx.yy.z.kk slave2

Then you can do scp with the known host like:

scp dir/etc/dir/file-site.xml slave1:/home/ubuntu/dir/etc/dir

Hope it helps.




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Donald Le

Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.