From 01ab62514b44f01d603ccb5ed9a70eae75b4a687 Mon Sep 17 00:00:00 2001 From: Deverick Date: Thu, 29 Sep 2022 13:56:23 -0500 Subject: [PATCH] Scp refactor (#3206) --- FAQ.cl.md | 2 +- home.admin/BlitzTUI/docs/tutorial.md | 2 +- home.admin/_background.sh | 24 +++++++++--------- home.admin/config.scripts/blitz.copychain.sh | 2 +- home.admin/config.scripts/blitz.migration.sh | 26 ++++++++++---------- home.admin/config.scripts/blitz.upload.sh | 2 +- home.admin/config.scripts/cl.backup.sh | 8 +++--- home.admin/config.scripts/lnd.backup.sh | 12 ++++----- home.admin/config.scripts/lnd.export.sh | 19 +++++++------- home.admin/config.scripts/lndlibs/README.md | 4 +-- home.admin/setup.scripts/dialogMigration.sh | 2 +- 11 files changed, 52 insertions(+), 51 deletions(-) diff --git a/FAQ.cl.md b/FAQ.cl.md index 102d89a1c..148b0d20c 100644 --- a/FAQ.cl.md +++ b/FAQ.cl.md @@ -479,7 +479,7 @@ Will need to pay through a peer which supports the onion messages which means yo * If there is no such file and you have not funded the CLN wallet yet can reset the wallet and the next wallet will be created with a seed. ### How to display the hsm_secret in a human-readable format? -* If there is no seed available it is best to save the hsm_secret as a file with `scp` or note down the alphanumeric characters in the two line displayed with: +* If there is no seed available it is best to save the hsm_secret as a file with `sftp` or note down the alphanumeric characters in the two line displayed with: ``` sudo xxd /home/bitcoin/.lightning/bitcoin/hsm_secret ``` diff --git a/home.admin/BlitzTUI/docs/tutorial.md b/home.admin/BlitzTUI/docs/tutorial.md index fee5d5e52..f1dc709fa 100644 --- a/home.admin/BlitzTUI/docs/tutorial.md +++ b/home.admin/BlitzTUI/docs/tutorial.md @@ -25,7 +25,7 @@ Your screen should look similar to this: * (3) this should be reflected in the preview Window * (4) save your changes -The next step is to transfer (use scp or WinSCP) the updated `home.ui` to the RaspiBlitz. +The next step is to transfer (use sftp or WinSCP) the updated `home.ui` to the RaspiBlitz. Login to your RaspiBlitz as **admin** (Password A) and change the directory to `~/raspiblitz/home.admin/BlitzTUI`. diff --git a/home.admin/_background.sh b/home.admin/_background.sh index bee2c912f..376de17af 100755 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -465,27 +465,27 @@ do fi fi - # check if a SCP backup target is set + # check if a SFTP backup target is set # parameter in raspiblitz.conf: - # scpBackupTarget='[USER]@[SERVER]:[DIRPATH-WITHOUT-ENDING-/]' - # optionally a custom option string for the scp command can be set with - # scpBackupOptions='[YOUR-CUSTOM-OPTIONS]' + # sftpBackupTarget='[USER]@[SERVER]:[DIRPATH-WITHOUT-ENDING-/]' + # optionally a custom option string for the sftp command can be set with + # sftpBackupOptions='[YOUR-CUSTOM-OPTIONS]' # On target server add the public key of your RaspiBlitz to the authorized_keys for the user # https://www.linode.com/docs/security/authentication/use-public-key-authentication-with-ssh/ - if [ ${#scpBackupTarget} -gt 0 ]; then - echo "--> Offsite-Backup SCP Server" - if [ "${scpBackupOptions}" == "" ]; then - scpBackupOptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + if [ ${#sftpBackupTarget} -gt 0 ]; then + echo "--> Offsite-Backup SFTP Server" + if [ "${sftpBackupOptions}" == "" ]; then + sftpBackupOptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" fi # its ok to ignore known host, because data is encrypted (worst case of MiM would be: no offsite channel backup) # but its more likely that without ignoring known host, script might not run thru and that way: no offsite channel backup - scp ${scpBackupOptions} ${localBackupPath} ${scpBackupTarget}/ - scp ${scpBackupOptions} ${localTimestampedPath} ${scpBackupTarget}/ + sftp ${sftpBackupOptions} ${localBackupPath} ${sftpBackupTarget}/ + sftp ${sftpBackupOptions} ${localTimestampedPath} ${sftpBackupTarget}/ result=$? if [ ${result} -eq 0 ]; then - echo "OK - SCP Backup exited with 0" + echo "OK - SFTP Backup exited with 0" else - echo "FAIL - SCP Backup exited with ${result}" + echo "FAIL - SFTP Backup exited with ${result}" fi fi diff --git a/home.admin/config.scripts/blitz.copychain.sh b/home.admin/config.scripts/blitz.copychain.sh index 3b9173c2c..00d6edcc6 100644 --- a/home.admin/config.scripts/blitz.copychain.sh +++ b/home.admin/config.scripts/blitz.copychain.sh @@ -141,7 +141,7 @@ if [ "$1" = "target" ]; then echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore." echo "" echo "COPY, PASTE & EXECUTE the following command on your Windows computer terminal:" - echo "scp -r ./chainstate ./blocks bitcoin@${internet_localip}:/mnt/hdd/bitcoin" + echo "sftp -r ./chainstate ./blocks bitcoin@${internet_localip}:/mnt/hdd/bitcoin" echo "" echo "If asked for a password use PASSWORD A (or 'raspiblitz')." fi diff --git a/home.admin/config.scripts/blitz.migration.sh b/home.admin/config.scripts/blitz.migration.sh index c8197a4b6..a66dc3434 100755 --- a/home.admin/config.scripts/blitz.migration.sh +++ b/home.admin/config.scripts/blitz.migration.sh @@ -26,21 +26,21 @@ defaultUploadPath="/mnt/hdd/temp/migration" # get local ip source <(/home/admin/config.scripts/internet.sh status local) -# SCP download and upload links -scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz' ./" -scpDownloadWin="scp -r bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz ." -scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}" -scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}" +# SFTP download and upload links +sftpDownloadUnix="sftp -r 'bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz' ./" +sftpDownloadWin="sftp -r bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz ." +sftpUploadUnix="sftp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}" +sftpUploadWin="sftp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}" # output status data & exit if [ "$1" = "status" ]; then echo "# RASPIBLITZ Data Import & Export" echo "localip=\"${localip}\"" echo "defaultUploadPath=\"${defaultUploadPath}\"" - echo "scpDownloadUnix=\"${scpDownloadUnix}\"" - echo "scpUploadUnix=\"${scpUploadUnix}\"" - echo "scpDownloadWin=\"${scpDownloadWin}\"" - echo "scpUploadWin=\"${scpUploadWin}\"" + echo "sftpDownloadUnix=\"${sftpDownloadUnix}\"" + echo "sftpUploadUnix=\"${sftpUploadUnix}\"" + echo "sftpDownloadWin=\"${sftpDownloadWin}\"" + echo "sftpUploadWin=\"${sftpUploadWin}\"" exit 1 fi @@ -433,8 +433,8 @@ if [ "$1" = "export" ]; then rm ~/.exclude.temp rm ~/.include.temp - echo "scpDownloadUnix=\"${scpDownloadUnix}\"" - echo "scpDownloadWin=\"${scpDownloadWin}\"" + echo "sftpDownloadUnix=\"${sftpDownloadUnix}\"" + echo "sftpDownloadWin=\"${sftpDownloadWin}\"" echo "# OK - Export done" exit 0 fi @@ -492,9 +492,9 @@ if [ "$1" = "export-gui" ]; then echo "*******************************" echo echo "On your Linux or MacOS Laptop - RUN IN NEW TERMINAL:" - echo "${scpDownloadUnix}" + echo "${sftpDownloadUnix}" echo "On Windows use command:" - echo "${scpDownloadWin}" + echo "${sftpDownloadWin}" echo "" echo "Use password A to authenticate file transfer." echo diff --git a/home.admin/config.scripts/blitz.upload.sh b/home.admin/config.scripts/blitz.upload.sh index f27ab1cd8..7bc47bb49 100644 --- a/home.admin/config.scripts/blitz.upload.sh +++ b/home.admin/config.scripts/blitz.upload.sh @@ -2,7 +2,7 @@ # command info if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then - echo "# use to prepare & check scp or web file upload to RaspiBlitz" + echo "# use to prepare & check sftp or web file upload to RaspiBlitz" echo "# blitz.upload.sh prepare-upload" echo "# blitz.upload.sh check-upload ?[scb|lnd-rescue|migration]" exit 0 diff --git a/home.admin/config.scripts/cl.backup.sh b/home.admin/config.scripts/cl.backup.sh index ff69cc47c..2ba3e7244 100644 --- a/home.admin/config.scripts/cl.backup.sh +++ b/home.admin/config.scripts/cl.backup.sh @@ -180,7 +180,7 @@ if [ ${mode} = "cl-export-gui" ]; then # get local ip info source <(/home/admin/config.scripts/internet.sh status local) - # offer SCP for download + # offer SFTP for download clear echo echo "*******************************************" @@ -188,9 +188,9 @@ if [ ${mode} = "cl-export-gui" ]; then echo "*******************************************" echo echo "ON YOUR MAC & LINUX LAPTOP - RUN IN NEW TERMINAL:" - echo "scp '${fileowner}@${localip}:${filename}' ./" + echo "sftp '${fileowner}@${localip}:${filename}' ./" echo "ON WINDOWS USE:" - echo "scp ${fileowner}@${localip}:${filename} ." + echo "sftp ${fileowner}@${localip}:${filename} ." echo echo "Use password A to authenticate file transfer." echo "Check for correct file size after transfer: ${size} byte" @@ -291,7 +291,7 @@ if [ ${mode} = "cl-import-gui" ]; then echo "To make upload open a new terminal on your laptop," echo "change into the directory where your cl-rescue file is and" echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" - echo "scp -r ./cl-rescue-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/" + echo "sftp -r ./cl-rescue-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/" echo echo "Use ${passwordInfo} to authenticate file transfer." echo "PRESS ENTER when upload is done" diff --git a/home.admin/config.scripts/lnd.backup.sh b/home.admin/config.scripts/lnd.backup.sh index 6215715a0..a527a7d73 100755 --- a/home.admin/config.scripts/lnd.backup.sh +++ b/home.admin/config.scripts/lnd.backup.sh @@ -190,7 +190,7 @@ if [ ${mode} = "lnd-export-gui" ]; then # get local ip info source <(/home/admin/config.scripts/internet.sh status local) - # offer SCP for download + # offer SFTP for download clear echo echo "********************************" @@ -198,9 +198,9 @@ if [ ${mode} = "lnd-export-gui" ]; then echo "********************************" echo echo "ON YOUR MAC & LINUX LAPTOP - RUN IN NEW TERMINAL:" - echo "scp '${fileowner}@${localip}:${filename}' ./" + echo "sftp '${fileowner}@${localip}:${filename}' ./" echo "ON WINDOWS USE:" - echo "scp ${fileowner}@${localip}:${filename} ." + echo "sftp ${fileowner}@${localip}:${filename} ." echo "Use password A to authenticate file transfer." echo echo "Check for correct file size after transfer: ${size} byte" @@ -299,7 +299,7 @@ if [ ${mode} = "lnd-import-gui" ]; then echo "To make upload open a new terminal on your laptop," echo "change into the directory where your lnd-rescue file is and" echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" - echo "scp -r ./lnd-rescue-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/" + echo "sftp -r ./lnd-rescue-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/" echo echo "Use ${passwordInfo} to authenticate file transfer." echo "PRESS ENTER when upload is done" @@ -413,7 +413,7 @@ if [ ${mode} = "scb-export-gui" ]; then echo "**************************************" echo echo "RUN THE FOLLOWING COMMAND ON YOUR LAPTOP IN NEW TERMINAL:" - echo "scp -r ${fileuser}@${localip}:${filename} ./" + echo "sftp -r ${fileuser}@${localip}:${filename} ./" echo "" echo "Use password A to authenticate file transfer." echo @@ -492,7 +492,7 @@ if [ ${mode} = "scb-import-gui" ]; then echo "To make upload open a new terminal and change," echo "into the directory where your lnd-rescue file is and" echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" - echo "scp ./channel.backup ${defaultUploadUser}@${localip}:${defaultUploadPath}/" + echo "sftp ./channel.backup ${defaultUploadUser}@${localip}:${defaultUploadPath}/" echo "" echo "Use ${passwordInfo} to authenticate file transfer." echo "PRESS ENTER when upload is done." diff --git a/home.admin/config.scripts/lnd.export.sh b/home.admin/config.scripts/lnd.export.sh index fa733765b..fa6307898 100755 --- a/home.admin/config.scripts/lnd.export.sh +++ b/home.admin/config.scripts/lnd.export.sh @@ -3,7 +3,8 @@ # command info if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo "tool to export macaroons & tls.cert" - echo "lnd.export.sh [hexstring|scp|http|btcpay] [?key-value]" + echo "lnd.export.sh [hexstring|sftp|http|btcpay] [?key-value]" + exit 1 fi @@ -20,7 +21,7 @@ exportType=$1 # interactive choose type of export if not set if [ "$1" = "" ] || [ $# -eq 0 ]; then OPTIONS=() - OPTIONS+=(SCP "SSH Download (Commands)") + OPTIONS+=(SFTP "SSH Download (Commands)") OPTIONS+=(HTTP "Browserdownload (bit risky)") OPTIONS+=(HEX "Hex-String (Copy+Paste)") OPTIONS+=(STR "BTCPay Connection String") @@ -39,8 +40,8 @@ if [ "$1" = "" ] || [ $# -eq 0 ]; then STR) exportType='btcpay'; ;; - SCP) - exportType='scp'; + SFTP) + exportType='sftp'; ;; HTTP) exportType='http'; @@ -142,21 +143,21 @@ elif [ "${exportType}" = "btcpay" ]; then echo "" ########################### -# SHH / SCP File Download +# SHH / SFTP File Download ########################### -elif [ "${exportType}" = "scp" ]; then +elif [ "${exportType}" = "sftp" ]; then local_ip=$(hostname -I | awk '{print $1}') clear - echo "###### DOWNLOAD BY SCP ######" + echo "###### DOWNLOAD BY SFTP ######" echo "Copy, paste and execute these commands in your client terminal to download the files." echo "The password needed during download is your Password A." echo "" echo "Macaroons:" - echo "scp bitcoin@${local_ip}:/home/bitcoin/.lnd/data/chain/${network}/${chain}net/\*.macaroon ./" + echo "sftp bitcoin@${local_ip}:/home/bitcoin/.lnd/data/chain/${network}/${chain}net/\*.macaroon ./" echo "" echo "TLS Certificate:" - echo "scp bitcoin@${local_ip}:/home/bitcoin/.lnd/tls.cert ./" + echo "sftp bitcoin@${local_ip}:/home/bitcoin/.lnd/tls.cert ./" echo "" ########################### diff --git a/home.admin/config.scripts/lndlibs/README.md b/home.admin/config.scripts/lndlibs/README.md index 269ac4552..94b003d8a 100644 --- a/home.admin/config.scripts/lndlibs/README.md +++ b/home.admin/config.scripts/lndlibs/README.md @@ -19,9 +19,9 @@ cp ./*.proto ./protobuffs *NOTE: If LND master branch is already a version ahead .. use the rpc.proto from the version tagged branch.* -Now copy the generated RPC libs per SCP over to your Laptop and add them to the `/home/admin/config.scripts/lndlibs`. +Now copy the generated RPC libs per SFTP over to your Laptop and add them to the `/home/admin/config.scripts/lndlibs`. -scp -r admin@192.168.X.X:/home/admin/protobuffs ./protobuffs +sftp -r admin@192.168.X.X:/home/admin/protobuffs ./protobuffs Make sure the first lines (ignore comments) of the `lightning_pb2_grpc.py` look like the following for python3 compatibility: ``` diff --git a/home.admin/setup.scripts/dialogMigration.sh b/home.admin/setup.scripts/dialogMigration.sh index 15bdbb1b3..2e7f183da 100755 --- a/home.admin/setup.scripts/dialogMigration.sh +++ b/home.admin/setup.scripts/dialogMigration.sh @@ -55,7 +55,7 @@ if [ "${migrationOS}" == "raspiblitz" ]; then echo "ON YOUR LAPTOP open a new terminal and change into" echo "the directory where your migration file is and" echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" - echo "scp -r ./raspiblitz-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/" + echo "sftp -r ./raspiblitz-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/" echo "" echo "Use password 'raspiblitz' to authenticate file transfer." echo "PRESS ENTER when upload is done."