1

I need to create /etc/apt/apt.conf on a remote server and add proxy details to it over ssh.

sshpass -p pass123 ssh -oStrictHostKeyChecking=no user@10.10.4.4 -p 234 cat <<EOL | 'sudo cat > /etc/apt/apt.conf'
Acquire::http::proxy "http://proxy.my.org.com:80"; 
Acquire::https::proxy "http://proxy.my.org.com:80/";
EOL

but it fails with -bash: /etc/apt/apt.conf: Permission denied .

On logging to the remote server, if I do vi /etc/apt/apt.conf it prompts for password.

How can I pass password twice, one during initial login and next during sudo ?

Chel MS
  • 386
  • 1
  • 10
  • `sshpass` is just for the local `ssh` command, it's not for sending passwords to other commands that are executed. – Barmar Jun 20 '22 at 15:48
  • @How can I remotely create that file ? – Chel MS Jun 20 '22 at 15:56
  • 1
    Does this answer your question? [How to pass the password to su/sudo/ssh without overriding the TTY?](https://stackoverflow.com/questions/233217/how-to-pass-the-password-to-su-sudo-ssh-without-overriding-the-tty) – tomgalpin Jun 20 '22 at 15:58
  • Simple echo password and piping that to `tee` worked – Chel MS Jun 20 '22 at 16:44

0 Answers0