scp or pscp transfer files to ssh machine but not showing any copied files in machine [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am using putty ssh client in windows to login to remote machine
I transfer files using scp and pscp from my local to server
scp:
scp -r script-1/ root#104.130.169.111:/mounarajan/script-1
Response in command line:
artist_dedup_urls1 100% 414KB 413.8KB/s 00:00
reverbnation_crawler.py 100% 21KB 21.0KB/s 00:00
pscp:
pscp -r script-1/ root#104.130.169.111:/mounarajan/script-1
Response in command line:
artist_dedup_urls1 | 413 kB | 413.8 kB/s | ETA: 00:00:00 | 100%
reverbnation_crawler.py | 21 kB | 21.0 kB/s | ETA: 00:00:00 | 100%
But after this the script-1 folder in server machine is empty.
Where is the problem actaully?

Did you deleted the "script-1" on 104.130.169.111 before? Your situation seems to be the same as this scenario:
On command window 1: cd to certain directory, say "a/b/c"
On another window: delete "a/b/c", recreate it and copy in some files
On command window 1: no change can be seen.
Solution is: on command window 1, cd to another directory and then cd back to "a/b/c" again to access the newly created directory

Related

Linux dd command: save file instead of upload file to server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have this command run on Finnix OS:
dd if=/dev/sda | pv | gzip -9 | ssh root#LinodeIP "gzip -d | dd of=/dev/sda"
I got it from this artical: https://github.com/ClickSimply/docs/blob/windows-on-linode/docs/tools-reference/windows-on-linode/installing-windows-on-linode-vps.md
And I understand that this command will compress a file using gzip, then upload it to a server and run gzip command in that server to extract it. My question is what is the right command to save the gzip file in local computer instead of sending it to a server?
Thank you so much.
dd if=/dev/sda | gzip -9 > /path/to/output/file.gz
should do it.
if you would still like to see the progress with pv then
dd if=/dev/sda | pv | gzip -9 > /path/to/output/file.gz
should be the way to go
EDIT: worth to note, cat is the best way in my opnion to do this nowadays, as it uses the full potential of the hardware. dd was OK where you were limited by the drive speed, (like tapes, still being used for backups nowadays in some places and dd is fine there)

Bash script check permissions to run command on remote [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a local development machine and from my bash script am sending commands to the remote server.
How can I write bash code to check if I am allowed to run the remote command so that I can handle the success/failure response from my script?
Alternatively, how can I capture the output so that I can parse it and detect if it succeeded. The difficulty with parsing is that the ssh command might trigger a password prompt so I can't interfere with that.
That bash script uses ssh -qt to send the remote commands
Command
ssh user#host -qt "sudo -u www /usr/local/bin/php /mnt/data/script.php"
Output:
[sudo] password for xxx:
Sorry, user xxx is not allowed to execute '/usr/local/bin/php /mnt/data/script.php' as www on host.domain.com
Assuming that user != root above: you can't - there's no way to read /etc/sudoers or /etc/sudoers.d/* in a normally set-up Linux box if you're not root, so apart from trial & error there's nothing to be done.
As for capturing the result - that's fairly simple (parsing it, of course, is a different story, depending on what you're doing over there).
output=$( ssh user#host -qt "sudo -u www /usr/local/bin/php /mnt/data/script.php" 2>&1 )
After the execution (and you typing the password for sudo)
echo $? # gives you the return-code of what happened on the far end, if it's a success that should be 0
echo $output # gives you the strings to parse

How do I run `forever` from Crontab? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I am trying to schedule node server restart on OS reboot (Ubuntu 16.04 LTS). I wrote:
crontab -u username -e
then I added following line:
#reboot /usr/local/bin/forever start -c /usr/bin/node /home/username/node/bin/www
I get the success message after saving or updating this file. There seems to be no effect on server reboot.
I'd wrap that into a bash script in the user's home directory's bin.
/home/username/bin/start_my_node_app.sh
Then in your crontab...
#reboot /home/username/bin/start_my_node_app.sh >/dev/null 2>&1
Though according to this article, #reboot may not work for non-root users.
https://unix.stackexchange.com/questions/109804/crontabs-reboot-only-works-for-root

How to copy files over ssh [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
How do I copy a file using ssh from my test server to my production server, how do I do this for a single file and how do I do this for multiple files?
From Window to Linux
Download https://cygwin.com/ this will give you a proper terminal which will then allow you to run the linux commands as listed below in the From Linux to Linux section.
From Linux to Linux
The essential command is this
The command
scp [ssh login to remote server]:[filepath] [local filepath]
To copy a single file example
scp user#your.server.example.com:/path/to/foo/[filename] /home/user/Desktop/[filename]
To copy a directory example
scp -r user#your.server.example.com:/path/to/foo /home/user/Desktop/
To use full power of scp you need to go through next steps:
Setup public key authentication
Create ssh aliases
Then, for example if you'll have this ~/.ssh/config:
Host test
User testuser
HostName test-site.com
Port 22022
Host prod
User produser
HostName production-site.com
Port 22022
you'll save yourself from password entry and simplify scp syntax like this:
scp -r prod:/path/foo /home/user/Desktop # copy to local
scp -r prod:/path/foo test:/tmp # copy from remote prod to remote test
More over, you will be able to use remote path-completion:
scp test:/var/log/ # press tab twice
Display all 151 possibilities? (y or n)

combing multiple commands when using ssh and scp [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am having multiple ssh commands to do some tasks for me. For eg:
ssh a-vm "rm -f /home/dir/file1.xlsx"
ssh a-vm "rm -f /home/dir/file2.xml"
scp me#b-vm:/somedir/file1.xlsx .
scp me#b-vm:/somedir/file2.xml .
1) Is there a way to combine 2 ssh commands into 1 and two scp commands into 1?
2) Is there a cost if I do ssh and scp multiple times instead of 1 time?
Any help is appreciated.
You can just do:
ssh a-vm "rm -f /home/dir/file1.xlsx ; rm -f /home/dir/file2.xml"
scp "me#b-vm:/somedir/{file1.xlsx,file2.xml}" .
Each ssh/scp call will cost you the connection time and some cpu time (could be significant if you do that to hundreds of machines at the same time, otherwise unlikely).
Alternatively you can use a persistent master connection for ssh and tunnel others over it. That will save a couple of network roundtrips - see http://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing

Resources