I want to use a LOCAL script to install ruby remotely on a server. Following is my code:
sshpass -p ****** ssh hx@$HOST 'bash -s' <<'ENDSSH'
export PATH=$PATH:/home/hx/.rvm/bin/
rvm install 2.2.0
ENDSSH
When I run this script, an error occurs saying:
Error running 'requirements_debian_update_system ruby-2.2.0',
showing last 15 lines of /home/hx/.rvm/log/1423392690_ruby-2.2.0/update_system.log
++ [[ -d /usr/sbin ]]
++ [[ :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/hx/.rvm/bin/:/home/hx/.rvm/bin: != *\:\/\u\s\r\/\s\b\i\n\:* ]]
++ for sbin_path in /sbin /usr/sbin /usr/local/sbin
++ [[ -d /usr/local/sbin ]]
++ [[ :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/hx/.rvm/bin/:/home/hx/.rvm/bin: != *\:\/\u\s\r\/\l\o\c\a\l\/\s\b\i\n\:* ]]
++ [[ -n '' ]]
++ command_to_run=(__rvm_sudo -p "%p password required for '$*': " "${command_to_run[@]}")
++ __rvm_sudo -p '%p password required for '\''apt-get --quiet --yes update'\'': ' apt-get --quiet --yes update
++ command sudo -p '%p password required for '\''apt-get --quiet --yes update'\'': ' apt-get --quiet --yes update
++ sudo -p '%p password required for '\''apt-get --quiet --yes update'\'': ' apt-get --quiet --yes update
sudo: no tty present and no askpass program specified
++ return 1
++ typeset __ret=1
++ case ${__ret} in
++ return 1
Requirements installation failed with status: 1.
make: *** [install-ruby] Error 1
It turns out that when running rvm install as a non-root user, it will ask you to input the password to update apt-get DURING the process.
Is there a way to automatically input the password within my script? Like
echo password | apt-get -S install xxxxxx