Skip to main content
added 551 characters in body
Source Link
Gabriel Staples
  • 3.1k
  • 3
  • 34
  • 52

Update: done! Here is what I came up with:

# Store your password into a file
echo "my_password" > ~/pw

# Manually add something like this to your ~/.bash_aliases (recommended) or ~/.bashrc file on the PC
# you are ssh-ing FROM:
alias gs_ssh="sshpass -f ~/pw scp /etc/skel/.bashrc [email protected]:/tmp \
&& sshpass -f ~/pw ssh -t -o 'ServerAliveInterval 60' [email protected] 'bash --rcfile /tmp/.bashrc'"

See my repo here: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/tree/master/home/.ssh#optional-but-recommended-alias.

Update: done! Here is what I came up with:

# Store your password into a file
echo "my_password" > ~/pw

# Manually add something like this to your ~/.bash_aliases (recommended) or ~/.bashrc file on the PC
# you are ssh-ing FROM:
alias gs_ssh="sshpass -f ~/pw scp /etc/skel/.bashrc [email protected]:/tmp \
&& sshpass -f ~/pw ssh -t -o 'ServerAliveInterval 60' [email protected] 'bash --rcfile /tmp/.bashrc'"

See my repo here: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/tree/master/home/.ssh#optional-but-recommended-alias.

added 246 characters in body
Source Link
Gabriel Staples
  • 3.1k
  • 3
  • 34
  • 52

 

Not a duplicate:

Related:

  1. [my own question] https://stackoverflow.com/questions/69891328/what-is-the-syntax-in-shell-bash-and-how-do-i-search-for-it

Notes to self

My end-goal is to automatically create some custom aliases when I ssh in, like this perhaps:

ssh -t username@ip_address '/bin/bash --rcfile <(
cat << EOF
alias foo="echo hey you"
EOF
)'

 

Not a duplicate:

Related:

  1. [my own question] https://stackoverflow.com/questions/69891328/what-is-the-syntax-in-shell-bash-and-how-do-i-search-for-it

Notes to self

My end-goal is to automatically create some custom aliases when I ssh in, like this perhaps:

ssh -t username@ip_address '/bin/bash --rcfile <(
cat << EOF
alias foo="echo hey you"
EOF
)'
Source Link
Gabriel Staples
  • 3.1k
  • 3
  • 34
  • 52

'-sh: syntax error: unexpected "("' when attempting process substitution on an embedded Linux device with `bash`

This uses "process substitution" (<()) and a "heredoc" (cat << EOF...EOF) to open a new bash process where it runs the startup "file" (--rcfile) containing alias foo="echo hey you. Here is the command:

bash --rcfile <(
cat << EOF
alias foo="echo hey you"
EOF
)

It works on Ubuntu just fine, as you can see here:

$ bash --rcfile <(
> cat << EOF
> alias foo="echo hey you"
> EOF
> )
$ foo
hey you
$ alias
alias foo='echo hey you'

However, when I try to run this on certain embedded Linux devices, I get the following error. Why? How do I make it run there too?

-sh: syntax error: unexpected "("

Full output:

$ bash --rcfile <(
-sh: syntax error: unexpected "("
$ cat << EOF
> alias foo="echo hey you"
> EOF
alias foo="echo hey you"
$ )
-sh: syntax error: unexpected ")"

In case this helps, here are my which bash and bash --version outputs on Ubuntu vs the embedded Linux device:

# 1. Ubuntu

$ which bash
/bin/bash
$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <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.


# 2. Embedded Linux device

$ which bash
/bin/bash
$ bash --version
GNU bash, version 5.0.16(1)-release (aarch64-buildroot-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <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.

This is related but does not seem to be a duplicate: dash reports 'Syntax error: "(" unexpected' when using process substitution.