Advertisement
Guest User

Untitled

a guest
Jan 27th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. set -e  #quit if command fails
  4. set -u  #quit if variable error
  5.  
  6. function connectioninfo() {
  7.     echo -n @address:
  8.     read osoite
  9.  
  10.     echo -n @user:
  11.     read user
  12.  
  13.     echo -n @ssh password:
  14.     read -s passu
  15.  
  16.     }  
  17. function filetransfer() {
  18.     echo File transfer started...
  19.     sshpass -p $passu scp /home/atte/testi.txt $user@$osoite:/home/administrator/testi
  20.     echo File transfer complete.
  21. }
  22.  
  23. function remotecommands() {
  24.     echo Executing commands...
  25.     sshpass -p $passu ssh $user@$osoite "bash -s" << EOF
  26.  
  27.         cd /home/administrator/testi
  28.         echo orderi
  29.         ls
  30.         rm testi.txt
  31.         ls
  32. EOF
  33. echo Commands executed.
  34.         }
  35.  
  36. connectioninfo
  37. filetransfer
  38. remotecommands
  39.  
  40.  
  41. echo Script finished. @attejantunen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement