Sometime to automates your script you'll to copy some file via scp or sftp or may you get bored to ssh to same server everyday and asking you the same password. Here's how to automated your scp, sftp, and ssh to login without password
1. Go to your home folder
2. Pass this step if you already has .ssh folder
3. Set private
4. Go to your ~/.ssh folder
5. Create a ssh public_key
6. Copy PUBLIC key ONLY to .ssh folder on target server
7. Now log into the remote server as the target user
8. Go to it's .ssh folder
9. Put your public key in the authorized keys file
10. Set privates the authorized_keys2
11. Delete the public key on the remote server
12. Exit the server
Now if everything is correct you should be able to ssh, scp and sftp to target server without password
Based on http://homepage.mac.com/kelleherk/iblog/C1901548470/E20061128145420/index.html
1. Go to your home folder
CODE:
$ cd ~
$ cd ~
2. Pass this step if you already has .ssh folder
CODE:
$ mkdir .ssh
$ mkdir .ssh
3. Set private
CODE:
$ chmod -R 0700 .ssh
$ chmod -R 0700 .ssh
4. Go to your ~/.ssh folder
CODE:
$ cd .ssh
$ cd .ssh
5. Create a ssh public_key
CODE:
$ ssh-keygen -t dsa -f id_dsa -P ''
$ ssh-keygen -t dsa -f id_dsa -P ''
6. Copy PUBLIC key ONLY to .ssh folder on target server
CODE:
$ scp id_dsa.pub user@server:~/.ssh
$ scp id_dsa.pub user@server:~/.ssh
7. Now log into the remote server as the target user
CODE:
$ ssh user@server
$ ssh user@server
8. Go to it's .ssh folder
CODE:
$ cd .ssh
$ cd .ssh
9. Put your public key in the authorized keys file
CODE:
$ cat id_dsa.pub >> authorized_keys2
$ cat id_dsa.pub >> authorized_keys2
10. Set privates the authorized_keys2
CODE:
$ chmod 0600 authorized_keys2
$ chmod 0600 authorized_keys2
11. Delete the public key on the remote server
CODE:
$ rm id_dsa.pub
$ rm id_dsa.pub
12. Exit the server
CODE:
$ exit
$ exit
Now if everything is correct you should be able to ssh, scp and sftp to target server without password
CODE:
$ ssh user@server
$ scp testfile.txt user@server:/data
$ ssh user@server
$ scp testfile.txt user@server:/data
Based on http://homepage.mac.com/kelleherk/iblog/C1901548470/E20061128145420/index.html
