In this article we will see how we can do SCP and SSH to remote server without giving any password.
This helps while we are writing a bash script for doing ssh and scp.
Run this command on LocalMachine
$ ssh-keygen -t dsa
Add following lines to your .bash_profile on your LocalMachine:
# So that ssh will work, take care with X logins - see .xsession
[[ -z $SSH_AGENT_PID && -z $DISPLAY ]] &&
exec -l ssh-agent $SHELL -c "bash --login"
Run these command on LocalMachine
Run these command on RemoteServer
$ cat ~/.ssh/id_dsa.pub.LocalMachine >> ~/.ssh/authorized_keys
$ rm ~/.ssh/id_dsa.pub.LocalMachine
$ chmod 600 ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh
After executing the above commands we will be able to SCP or SSH to RemoteServer from LocalMachine.
This helps while we are writing a bash script for doing ssh and scp.
Run this command on LocalMachine
$ ssh-keygen -t dsa
Add following lines to your .bash_profile on your LocalMachine:
# So that ssh will work, take care with X logins - see .xsession
[[ -z $SSH_AGENT_PID && -z $DISPLAY ]] &&
exec -l ssh-agent $SHELL -c "bash --login"
Run these command on LocalMachine
$ ssh-copy-id RemoteServer
$ scp ~/.ssh/id_dsa.pub RemoteServer:.ssh/id_dsa.pub.LocalMachineRun these command on RemoteServer
$ cat ~/.ssh/id_dsa.pub.LocalMachine >> ~/.ssh/authorized_keys
$ rm ~/.ssh/id_dsa.pub.LocalMachine
$ chmod 600 ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh
After executing the above commands we will be able to SCP or SSH to RemoteServer from LocalMachine.
No comments:
Post a Comment