

You can copy files from the remote host to your local machine: $ scp :"~/Documents/ssh_test.txt". You can also rename the file while copying: $ scp hello.txt :"~/Documents/ssh_test.txt" Scp: /Users/armin/DoesNotExist/: No such file or directory If the remote path does not exist, then scp will present an error: $ scp hello.txt :"~/DoesNotExist/" Like cp, when the source is a file and the destination is a directory, then the file will be placed into the destination directory. If the remote user has a different name, use: $ scp hello.txt do not want the local shell to evaluate the ~ to the local home directory, but want the remote computer to evaluate ~ to the remote user’s home directory, so we have to quote the remote path. Since no user name is given before the hostname (separated with an scp uses the username that you are logged in with on the local computer. This command will prompt for the user’s password on the remote host, unless you have added your public key to the remote host’s authorized_keys file. (though with these small files, you will not see much of it) You can suppress the progress display with the -q (quite) option.įor the destination, the colon : separates the hostname (DNS) from the file path. scp will show an ascii progress bar for every file copied. This will copy the local file sample.txt from the current working directory to the remote host’s ~/Documents/ directory.

To simplify this, a few examples: $ scp hello.txt :"~/Documents/" To create one quickly, simply type echo "Hello SSH" > hello.txt in Terminal.) The command you use for this is scp (secure copy) and it use the same basic syntax as the cp command $ scp source destinationīut, since scp can copy from the local computer to a remote host or vice versa, you usually add a bit more information: $ scp examples will use a file name hello.txt. You can also use the ssh connection to copy files to and from a remote host.

However, ssh has a few more powerful tools available. You can also send individual commands and receive and process the results. It allows to open one or more full command line sessions to remote computers as if we sat at their keyboard. it ‘merely’ provides a secure connection to connect to the default shell on the host itself.Įven this basic use of ssh is already very useful and powerful. In the previous posts we looked how to connect with ssh to a remote computer (host) and how to setup the keys necessary for a secure connection.ĭespite the name ssh does not actually provide a shell or command line interface to the host itself. Please consider supporting Scripting OS X by buying one of my books!
