I am trying to create a shell script that will automatically scp using my private key, a port of my choosing and to a commonly used user account (not my own account). I was able to accomplish this for ssh by doing the following.
####!/bin/bash
ssh -p (port#) <port #> -i ~/.ssh/.id_dsa -o StrictHostKeyChecking=no -l admin $@
For scp I have the following so far.
####!/bin/bash
scp -P (port#) -i ~/.ssh/.id_dsa $1 admin $@
If I try running my command without specifying the username I get the following.
user:~$ scputil <file to transfer> host:/tmp
[email protected]'s password:
As you can see it is asking for the password of my user when I was hoping it would use admin.
If I specify the user along with my command it works as I would expect
user:~$ scputil <file to transfer> [email protected]:/tmp/
<file to transfer> 22% 78MB 13.1MB/s 00:20 ETA
Does anyone know of a way to specify the user for the file transfer within the shell script?
Thanks in advance!