# remote backup via telnet or ssh?



## potobenka (Dec 16, 2009)

Hi I'd like know how to remotely backup my files via telnet or ssh? I am a super noob, just installed FreeBSD and working my way around it. I know one for ssh but it requires password which is not good when automating the task. Here's the command:



> # tar zcvf - /wwwdata | ssh root@www.nothing.com "cat > /backup/wwwdata.tar.gz"



Anyone know how to modify this so it would autologin?

As for telnet, how? I haven't found how to for it.. Pls help...


----------



## J65nko (Dec 16, 2009)

See Howto: Setting up public key password-less 'ssh' access


----------



## potobenka (Dec 16, 2009)

J65nko said:
			
		

> See Howto: Setting up public key password-less 'ssh' access



hi just followed the tutorial. However when try to copy the key using a wheel user of the server, it says 



> cannot create /root/.ssh/authorized_keys: Permission denied



Am missing something? 
Also created the /root/.ssh/athorized_keys myself in the server. Is there one that already exists the acts the same thing?


----------



## potobenka (Dec 16, 2009)

i don't get it, I have changed the permission of the authorized_keys to 777 so I can write into it. After succeeding, I am still asked for a  password when I login to the server.. Any idea???


----------



## crsd (Dec 16, 2009)

Check /var/log/auth.log.


----------



## phoenix (Dec 16, 2009)

authorized_keys needs to be *rw-------* (perms 600), and the .ssh/ directory needs to be *rwx------* (perms 700).  IOW, only the specified user can read that file.

You really don't want to be doing this as root, by the way.  Use a normal user account, one that is **only** used for the purpose of transfering the backups.  Don't make this user part of wheel.  Don't make this user with sudo permissions.  And only give it write permissions to the directory where you will be storing the backups.

If possible, consider using security/scponly, so that the backups user doesn't even have a login, and can only use the scp command to transfer the backups from the client to the remote server.


----------



## malexe (Dec 18, 2009)

You need to activate the support for PKI in you sshd_config on the server.


```
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys
```


----------



## Levenson (Dec 22, 2009)

You should use a rsync for that.  Rsync + ssh -i works grate for me.
Take a look at this link.


----------



## SirDice (Dec 22, 2009)

potobenka said:
			
		

> hi just followed the tutorial. However when try to copy the key using a wheel user of the server,


Do NOT use root or any other wheel user for this. Create a backup user and set up ssh public/private key authentication. Use that account the ssh the data.


----------

