Today I struggled with downloading a file through ssh.
I can ssh through server with account quynh.nguyen. However, in order to read the file, I must use another account
sudo -i -u someuser
Then when I issue a request to download a file from remote server to local machine. It’ll ask me for the password of someuser, which I do not have. I only have password of user quynh.nguyen.
scp email@example.com:home/someuser/some_file.txt ~/local_directory
The solution seems to be trivial, but I spent around 3 hours with the help of some friends to figure it out.
- ssh to server with quynh.nguyen account
- Use the shell of someuser
- scp to copy file from someuser to quynh.nguyen home folder. Then I’ll input the password for user quynh.nguyen
- scp to copy file from home folder of quynh.nguyen to local folder in my machine
Below is the code:
su -i -u someuser
scp /home/someuser/some_file.txt firstname.lastname@example.org:/home/quynh.nguyen/some_file.txt