Why can't scp's prompt be hidden?

Source: Internet
Author: User
Why can't the scp prompt hide and redirect the scp standard output and standard errors to a file? why can the & quot; Enterwindowspassword: & quot; string be played on the shell interface? Scpfromfilenameusername@x.x.x.x:/topath/tofilename2 & gt; & amp; 1 scp prompt for why hidden not to redirect scp standard output and standard errors to a file, why can I still use the "Enter windows password:" string on the shell interface? Scp fromfilename username@x.x.x.x:/topath/tofilename 2> & 1>/tmp/tmp.txt Enter windows password: check the openssh code, the answer is very obvious. Char * readpassphrase (const char * prompt, char * buf, size_t bufsiz, int flags) {ssize_t nr; int input, output, save_errno; char ch, * p, * end; struct termios term, oterm; struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm; struct sigaction savetstp, savettin, savettou, savepipe; /* I suppose we cocould alloc on demand in this case (XXX ). */if (bufsiz = 0) {errno = EINVAL; return (NULL);} restart: signo = 0;/** Read and write to/dev/tty if available. if not, read from * stdin and write to stderr unless a tty is required. */if (flags & RPP_STDIN) | (input = output = open (_ PATH_TTY, O_RDWR) =-1) {if (flags & RPP_REQUIRE_TTY) {errno = ENOTTY; return (NULL);} input = STDIN_FILENO; output = STDERR_FILENO;}/** Catch signals that wowould otherwise cause the user to en D * up with echo turned off in the shell. don't worry about * things like SIGXCPU and SIGVTALRM for now. */sigemptyset (& sa. sa_mask); sa. sa_flags = 0;/* don't restart system CILS */sa. sa_handler = handler; (void) sigaction (SIGALRM, & sa, & savealrm); (void) sigaction (SIGHUP, & sa, & savehup); (void) sigaction (SIGINT, & sa, & saveint); (void) sigaction (SIGPIPE, & sa, & savepipe); (void) sigaction (SIGQUIT, & s A, & savequit); (void) sigaction (SIGTERM, & sa, & saveterm); (void) sigaction (SIGTSTP, & sa, & savetstp); (void) sigaction (SIGTTIN, & sa, & savettin); (void) sigaction (SIGTTOU, & sa, & savettou);/* Turn off echo if possible. */if (input! = STDIN_FILENO & tcgetattr (input, & oterm) = 0) {memcpy (& term, & oterm, sizeof (term); if (! (Flags & RPP_ECHO_ON) term. c_lflag & = ~ (ECHO | ECHONL); # ifdef VSTATUS if (term. c_cc [VSTATUS]! = _ POSIX_VDISABLE) term. c_cc [VSTATUS] = _ POSIX_VDISABLE; # endif (void) tcsetattr (input, _ T_FLUSH, & term);} else {memset (& term, 0, sizeof (term )); term. c_lflag | = ECHO; memset (& oterm, 0, sizeof (oterm); oterm. c_lflag | = ECHO;} if (! (Flags & RPP_STDIN) (void) write (output, prompt, strlen (prompt); end = buf + bufsiz-1; for (p = buf; (nr = read (input, & ch, 1) = 1 & ch! = '\ N' & ch! = '\ R';) {if (p <end) {if (flags & RPP_SEVENBIT) ch & = 0x7f; if (isalpha (ch )) {if (flags & RPP_FORCELOWER) ch = tolower (ch); if (flags & RPP_FORCEUPPER) ch = toupper (ch );} * p ++ = ch;} scp runs an ssh sub-process to complete connection authentication. 13996 root/usr/local/bin/ssh-x-oForwardAgent no-oPermitLocalCommand no-oClearAllForwardings yes-lusername x. x. x. x scp-t/topath/tofilename root @ 444444 []:/proc/13996/fd> Ls-lrt total 0 lrwx ------ 1 root 64 Jan 4 04:12 9->/tmp/lock/lock9997 lrwx ------ 1 root 64 Jan 4 04:12 6->/dev/tty lrwx ------ 1 root 64 Jan 4 5-> socket: [158339] lrwx ------ 1 root 64 Jan 4 4-> socket: [158338] lrwx ------ 1 root 64 Jan 4 3-> socket: [160359] lrwx ------ 1 root 64 Jan 4 2->/dev/pts/0 l-wx ------ 1 root 64 Jan 4 1-> pipe: [160353] lr-x ------ 1 root 64 Jan 4 0-> pipe: [160352] from now on, ssh directly writes/dev/tty through file descriptor 6 to display the prompt to the shell interface, which has nothing to do with standard output 1/Standard error 2. Lrwx ------ 1 root 64 Jan 4 6->/dev/tty
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.