Search code examples
linuxsshscp

Is there a way to provide some option to SCP to show host name or IP address while prompting for pasword


For eg:

In my machine the pwd prompt is always displayed as "Password"

$ scp sources/update_git.sh root@xx.213.xx.xx:/sds

Password:

But I need something like below

$ scp sources/update_git.sh root@xx.213.xx.xx:/sds

root@xx.213.xx.xx's password:


Solution

  • Make sure password authentication is enabled on the server. In /etc/ssh/sshd_config:

    PasswordAuthentication yes
    

    On the client side, set password as the preferred method

    ssh -o PreferredAuthentications=password server2
    

    It is sensible to add the keyboard-interactive method to the list in case the server has PasswordAuthentication disabled

    ssh -o PreferredAuthentications=password,keyboard-interactive server2
    

    I ended up adding the following to my .ssh/config:

    Host *
        ServerAliveInterval 120
        VerifyHostKeyDNS yes
        PreferredAuthentications publickey,password,keyboard-interactive