3 mv would be incorrect here since the question explicitly requests to overwrite, not replace, the existing file
source | link
ssh host "cd path/to/directory && cp image1.png image2.png"

The ssh host "cd path/to/directory && cp image1.png image2.png"

EDIT: Some explanations is safer than ; in case the cd fails, e.g. because of a typo: in such a case, the cp won't be executed instead of possibly copying a wrong file.

  • The && is safer than ; in case the cd fails, e.g. because of a typo: in such a case, the cp won't be executed instead of possibly copying a wrong file.
  • Use mv (move) instead of cp (copy) if you don't want to keep the original file image1.png. You get the idea...

ssh host "cd path/to/directory && cp image1.png image2.png"

EDIT: Some explanations:

  • The && is safer than ; in case the cd fails, e.g. because of a typo: in such a case, the cp won't be executed instead of possibly copying a wrong file.
  • Use mv (move) instead of cp (copy) if you don't want to keep the original file image1.png. You get the idea...
ssh host "cd path/to/directory && cp image1.png image2.png"

The && is safer than ; in case the cd fails, e.g. because of a typo: in such a case, the cp won't be executed instead of possibly copying a wrong file.

2 explanations
source | link

ssh host "cd path/to/directory && cp image1.png image2.png"

EDIT: Some explanations:

  • The && is safer than ; in case the cd fails, e.g. because of a typo: in such a case, the cp won't be executed instead of possibly copying a wrong file.
  • Use mv (move) instead of cp (copy) if you don't want to keep the original file image1.png. You get the idea...

ssh host "cd path/to/directory && cp image1.png image2.png"

ssh host "cd path/to/directory && cp image1.png image2.png"

EDIT: Some explanations:

  • The && is safer than ; in case the cd fails, e.g. because of a typo: in such a case, the cp won't be executed instead of possibly copying a wrong file.
  • Use mv (move) instead of cp (copy) if you don't want to keep the original file image1.png. You get the idea...
1
source | link

ssh host "cd path/to/directory && cp image1.png image2.png"