My goal is to copy a folder from a remote server to a new local machine via script. I run the script from deploystudio so this is all done in root.So the script is suppose to
1) create .ssh and authorized_keys folder on the local machine
2) Paste the remoteserver's id_dsa.pub into the local authorized_keys file
3) Secure copy Folder1 from the remote server to local machine's Desktop
The Folder1 fails to copy over. If I sudo the SCP line and manually run it, it would work after I enter the password.
user="name"
id_dsa.pub="ssh-dss AAAAB3NzaC1kc3MAAACBAPpK/k7Yk............"
mkdir /Users/${user}/.ssh
chmod 0700 /Users/${user}/.ssh
touch /Users/${user}/.ssh/authorized_keys
chmod 0644 /Users/${user}/.ssh/authorized_keys
/bin/cat > "/Users/${user}/.ssh/authorized_keys" << EOL
${id_dsa.pub}
EOL
scp -r [email protected]:/Users/admin/Desktop/Folder1 /Users/$user/Desktop
authorized_keys
withsudo
? You’re running as root anyway. Are you sure the username on the server at 192.168.1.39 is supposed to beremoteserver
? – Christopher Creutzigvariable="some string"
And always quote your strings and variables – Reinstate Monica Please