It is a good idea to use keys to login via ssh and sftp.
But you need a tool for other log in scenarios too. So I made a small shellscript, that you should run in a terminal window. I have tested it, and it works for passwords in ssh and sftp as well as for sudo. You should run the program that wants a password in another window. I hope it will help you (and maybe other people too)
This script works for sudo, but there is another script for that purpose - and it is more convenient to use. See the next post.
I use the name show-only for the shellscript.
Code:
#!/bin/bash
# Copyright 2016 Nio Wiklund
#
# GPLv3: GNU GPL version 3
# <http://gnu.org/licenses/gpl.html>.
#
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
#-----------------------------------------------------------------------
# author sudodus alias nio-wiklund at launchpad
#
# date editor comment
# 2016-04-15 sudodus created
cursorup="\0033[A"
function select_text {
/bin/echo $* | xsel -pi
/bin/echo $* | xsel -bi
}
# ----------------------------------------------------------------------
# main
# ----------------------------------------------------------------------
# Do it
echo "Enter passphrase (finish with the Enter key) "
read ans
select_text "$ans"
# Overwrite text string (variable and on screen) and prompt to use it
ans="1234567890qwertyuiopasdfghjkl*zxcvbnm,.-1234567890qwertyuiopasdfghjkl'"
ans=""
/bin/echo -e "${cursorup}In another window: Pull-down menu: Edit -- Paste (or middle-click) ..."
read -p "... clear the selection buffers afterwards (finish with the Enter key) " ans
# Overwrite selections
ans="echo '1234567890qwertyuiopasdfghjkl*zxcvbnm,.-1234567890qwertyuiopasdfghjkl'"
select_text -n "$ans"
ans=""
select_text -n "$ans"
I would copy and paste from this code window to gedit and save it into ~/bin
Code:
cd # brings you 'home'
mkdir bin
gedit show-only # copy and paste the shellscript code, save it and exit from gedit.
Then I would make it executable
Code:
chmod ugo+x show-only
and the next time you reboot it should be in PATH, so that you can run it with
See for more details.
Example:
Type in window #1:
Code:
$ show-only
Enter passphrase (finish with the Enter key)
echo 'Hello Anna'
Press Enter in window #1:
Code:
$ ./show-only
Enter passphrase (finish with the Enter key)
In another window: Pull-down menu: Edit -- Paste (or middle-click) ...
... clear the selection buffers afterwards (finish with the Enter key)
Use the pull-down menu: Edit -- Paste (or middle-click) in window #2:
Code:
$ echo 'Hello Anna'
Hello Anna
$
Press Enter in window #1:
Code:
$ ./show-only
Enter passphrase (finish with the Enter key)
In another window: Pull-down menu: Edit -- Paste (or middle-click) ...
... clear the selection buffers afterwards (finish with the Enter key)
$
Check that the selection buffers are empty in any window:
1. Use the pull-down menu: Edit -- Paste
2. Middle-click
Nothing should happen, now that the selection buffers are empty.
Bookmarks