Using SSH And SCP

Secure

SSH and SCP command line tools are very similar in usage. Both utilise a secure connection. Data is encrypted to ensure secure transit. Passwords and other sensitive data is safe.

Using SSH

You must have a user account and password on the remote host or connection will fail. The remote host must be running ssh server. You can check for sshd using ps and grep.

ps -e | grep sshd
1493 ?        00:00:00 sshd

Another consideration is a firewall that blocks connections to port 22. If you cannot connect to the remote host, check firewall settings.

To log into a remote host using ssh, do:

ssh remotehost
myname@remotehost password:

Enter the password for the account on the remote host to gain access.

Using SCP

Using scp is similar to using ssh, in how you log in to the remote host. Once your in, the similarity ends.

To copy files from a remote host into the current directory do:

scp myname@remotehost:/filetocopy .

Notice the colon after the host name. Its important. Followed by the path to the file you want to copy. Finally at the end the dot '.' or period. That tells Linux to place the copied file in this directory. The dot is short hand for 'the current directory'.

Copying files from my box to a remote host is pretty much the same command, rehashed.

scp filetocopy myname@remotehost:/directory/to/copy/to

Give it a shot. See how ya go.

That's about it.

Done!

No comments:

Post a Comment