Friday, April 18, 2008

Using ssh and scp without a password

ssh and scp are very useful for making sure you work in a pretty secure environment. But sometimes it can be a hassle if you have to keep on keying in your password to login many times to the server or you might need to write a backup script but do not want to write your password in the script then I have found a solution at https://help.ubuntu.com/community/SSHHowto#public-key-auth. Basically what you need to do is copy your public key to the authorized keys file on the server. If you haven't got a public key yet just type in:
ssh-keygen -t dsa

And that will create an id_dsa.pub file in your ~/.ssh folder (By default, you can set it in other places if you want). Anyway, copy the content of that file (it should be just one line) into the ~/.ssh/authorized_keys file on the server you want to login. Now whenever you ssh username@server you'll access it straight away without any password. And scp also works without password so you can write those scripts.

 Update: dsa doesn't seem to work anymore. Try using rsa.

No comments:

Is Blogging No Longer a Thing?

As I embark on my new journey to learn the Rust programming language, I find myself pondering—where have all the blogs gone? In search of pr...