SCP from remote to local script not copying

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 remoteserver@192.168.1.39:/Users/admin/Desktop/Folder1 /Users/$user/Desktop

Creating that file on the local system does not help you connect to the remote system. For that you want to use ssh-copy-id

链接地址: http://www.djcxy.com/p/25726.html

上一篇: 作家和自定义阅读器不像广告一样工作

下一篇: 从远程到本地脚本的SCP不复制