-1

Whenever I have to login to a remote server, I have to enter ssh username@hostname and subsequently a password.

I want to save time by omitting some parameters whenever I try to login to a server. I know that one can do this:

sshpass -p 'YourPassword' ssh username@hostname

Is there anyway I can define a function in .bashrc so that I only have to type ssh hostname and it will automatically log me in?

030
  • 1,557
  • 1
    http://unix.stackexchange.com/questions/131882/ssh-login-doesnt-work-using-a-key-without-password/131895#131895 – Nidal Sep 14 '14 at 04:54
  • 2
    man ssh_config and add an entry for that host... – jasonwryan Sep 14 '14 at 04:55
  • 2
    Look at my answer to this Q: http://unix.stackexchange.com/questions/116019/why-are-rules-not-combining-in-an-ssh-config-file – slm Sep 14 '14 at 05:22

1 Answers1

2

You can do this by setting up your ~/.ssh/ssh_config file and using public-key authentication. For each server you want to log into, set up a Host section in the file with appropriate User and IdentityFile entries.

See man ssh_config for more information.

Mark
  • 4,244