Question

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
Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top