Skip to content

Ssh connection¤

  1. ssh username@server
  2. ssh username@groupname@jumpserver server

Ssh without password¤

sshpass

Download sshpass link

cd folder
./configure
make install

with password¤

sshpass -p your-pwd ssh username@server

sshpass -p your-pwd scp -r username@server:/tmp/* ~/Desktop/

with password file¤

echo your-pwd > /tmp/pwd.txt

sshpass -f /tmp/pwd.txt ssh username@server

sshpass -f /tmp/pwd.txt scp -r username@server:/tmp/* ~/Desktop/

with a user¤

ssh -l user username@server

multi line command execution¤

localVar="test"
read -r -d '' command << EOM
echo "${localVar}"
cd /remote/path
git pull
process=\$(ls -la | awk '{print \$1}')
echo "\${process}"
EOM

ssh username@server "${command}"
ssh username@server << 'ENDSSH'
cd /remote/path
git pull
process=$(ls -la | awk '{print $1}')
echo "${process}"
ENDSSH
Back to top