How can I add password of user as alias in bashrc file?

15,182

Before we start, it's not a good thing to do... you should use ssh keys instead!

You can use sshpass, it's a non-interactive ssh password authentication.

Install it using your package manager, for example in Debian based distributions:

sudo apt install sshpass

then in your bashrc:

alias yb="sshpass -p password_in_plain_text ssh name@hostname"
Share:
15,182

Related videos on Youtube

Ramesh Kumar
Author by

Ramesh Kumar

Machine Learning and NLP Enthusiast

Updated on September 18, 2022

Comments

  • Ramesh Kumar
    Ramesh Kumar almost 2 years

    I have created alias for username and it works fine

    alias yb="ssh name@hostname"
    

    It works fine, but I also want to create alias for password, Can anyone help how can I do this?

  • Abhinav Ravi
    Abhinav Ravi about 5 years
    For Mac : Install "sshpass" using "brew install raw.githubusercontent.com/kadwanev/bigboybrew/master/Library‌​/…"
  • ankit
    ankit about 5 years
    Why it's not a good thing?
  • Ravexina
    Ravexina almost 5 years
    I'm user (A), there is a user (B) using the same machine. I can use cat /home/b/.bashrc to see what B got there.
  • roottraveller
    roottraveller almost 5 years
    this is not working on my mac. any idea
  • Andhi Irawan
    Andhi Irawan over 4 years
    not working in Ubuntu