MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Tue, Jun 30, 2015 10:09 pm

Transferring files with scp through a bastion host on an OS X system

I need to transfer files through a bastion host periodically. To edit files on a webserver, I need to first establish a Secure Shell (SSH) connection to the bastion host, logging in using an RSA SecurID token. Once I've provided my login credentials, the bastion host prompts me for the system to which I want to connect to from it, which in this case is the web server. So my ssh login to the webserver is tunneled through the bastion host.

I normally go through the process once a month from my MacBook Pro laptop running the OS X operating system when I need to place a monthly newsletter on the web server. I use an SSH command similar to the following to log into the bastion host where is the fully qualified domain name (FQDN) of the web server and is the bastion host.

ssh -L

The -L option specifies I want to tunnel a local port on my laptop, in this case I chose 22001, to port 22 on the web server, A tunnel is set up from my laptop to the web server through the bastion host by using that option once my login is completed to the bastion host.

Then, to transfer a file via secure copy from my laptop to the web server, I can use a command like the following one to transfer a file named July.txt from the laptop to the web server:

$ scp -P 22001 July.txt jasmith1@
jasmith1@'s password:

The -P option to the scp command specifies I want to use TCP port 22001, since that is the port for the end of the tunnel on my laptop. The address I'm specifying is the localhost, aka "loopback", address on my laptop. I.e., I'm connecting to port 22001 on the laptop itself. The tunnel I set up earlier results in any connection to that port being forwared through the tunnel to the web server, so I'm specifying my userid for the web server and the password prompt I receive is for the web server. The file July.txt will thus be placed in the directory /data/htdocs/clubs/groot/newsletter/2015 on the web server with the same name, July.txt.

If I wanted to pull a file from the webserver via the tunnel, I could use a command such as the following:

scp -P 22001 jasmith1@ .

That command would retrieve the file July.html from the web server and place it on the laptop with the same name.

[/network/ssh] permanent link

Once You Know, You Newegg AliExpress by

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo