I am not sure to clearly understand what you are looking for. Do you want to run a Bash script on your local computer, that does nothing but call
scp (which handles key authentication with
ssh internals)? Or is it on the remote server that you want to run your script? Or do you, perhaps, want to use a particular public key?
To run a command or script in background, whilst preventing its process to stop when it receives a SIGHUP signal from your terminal (ie. when you close it), you may use
nohup <command or script> &.
Assuming your script is named
script.sh, you could run it with
nohup script.sh &. The script could be running the following command (if you want to force a particular public key):
scp -B -i /home/user/.ssh/id_rsa_key.pub /path/to/your/files firstname.lastname@example.org:.
If not having to use a script file, or simplifying the command, is what you are after, you could always use your
~/.ssh/config file for that:
IdentityFile ~/.ssh/id_rsa_key.pub # If you need to force a particular key
Port 22 # Not necessary either, port 22 is default
So the command to run could be as “simple” to run as
nohup scp /path/to/your/files RemoteServer:. &
Feel free to tell me more about your configuration and/or what you exactly want to achieve, and I shall edit my answer to reflect the changes.