How to get password prompt from scp when launched remotely via ssh

Posted on

How to get password prompt from scp when launched remotely via ssh – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, ssh, scp, , .

When I ssh to a remote system and execute scp, I do not get a password prompt:

# ssh 192.168.1.32 "scp joe@192.168.1.31:/etc/hosts /tmp"  
Permission denied, please try again.  
Permission denied, please try again.  
Permission denied (publickey,password,keyboard-interactive).

If I break it up like this, it works fine:

# ssh 192.168.1.32  
# scp joe@192.168.1.31:/etc/hosts /tmp  
joe@192.168.1.31's password:

How can I make it prompt me for the password in the first example above?

Note: No, I cannot use key-based authentication for this.

Solution :

Try -t. From the ssh man page:

 -t      Force pseudo-tty allocation.  This can be used to execute arbi‐
         trary screen-based programs on a remote machine, which can be
         very useful, e.g. when implementing menu services.  Multiple -t
         options force tty allocation, even if ssh has no local tty.

What is probably happening is that scp is trying to read from the tty and failing because there isn’t one.

Leave a Reply

Your email address will not be published.