Sponsored Content
Top Forums Shell Programming and Scripting Copying a text file from my Ubuntu Windows Sub System to a remote instance through SSH Post 303027641 by Suhaba on Thursday 20th of December 2018 07:55:46 PM
Old 12-20-2018
Copying a text file from my Ubuntu Windows Sub System to a remote instance through SSH

*Following questions involves use of YAML, BASH, SSH and Software called Ansible*

I am trying to learn how to use a Linux environment (in my case a Ubuntu Windows Sub System) to copy a text file from my files to a remote instance (in this case Amazon Web Services) by connecting via SSH.

I have set up directories and files in Ubuntu like so:

hosts > my_hosts
playbook.yml
roles>my-role>files>test.txt
roles>my-role>tasks>main.yml

(hosts, playbook.yml, roles are all directories in home; hope the way I have shown it makes it clear)

The test.txt file contains a simple statement saying "Hello, World"; and this is what I want to send of to my remote instance.

The contents of the YAML files are as follows:

main.yml :
---
- name: Copy a file to the remote host
copy:
src: test.txt
dest: /tmp/test.txt

playbook.yml :
---
- hosts: my_hosts
roles:
- my-role

I am able to connect to the Amazon Web Services Remote Instances using a command in the following format:

sudo ssh -i ansible_instance_d**_****.pem "ubuntu@ec2-**-***-**-***.compute-1.amazonaws.com"
(ignore quotation marks)

I assume I now need to somehow add something in the text file my_hosts that will allow me to connect to the remote instance; and subsequently copy the text file.

In order to then run the process is use:

ansible-playbook -i hosts playbook.yml

But i don't know what to put in the my_hosts file or whether everything else i have done is correct.

I've tried my best to explain what I am trying to do, please ask any more questions to help clarify.


Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying files from laptop to remote server using SSH

Hello, I'm sorry if this sounds like a very simple question, but I'm having some difficulty with it being a complete newbie to UNIx. I use Windows, and always have, but need some UNIX access for work, picking up files from our group space, etc. Basically, I'm using Cygwin and can SSH into the... (3 Replies)
Discussion started by: patwa
3 Replies

2. UNIX for Dummies Questions & Answers

Copying files from a remote server to local system with cygwin

Hi. I'm sorry if I get on people's nerves asking this, but I don't really understand how to do this and unfortunately don't have the time to work through it step by step in books, etc. At University, we have a unix server that hosts our files. we each have a login and password to access it. I... (3 Replies)
Discussion started by: patwa
3 Replies

3. Shell Programming and Scripting

ssh text into file on remote server

Hello, I have about 90 servers that I need to update snmp configs. I am trying to write a script that will echo 4 new lines of text into the snmpd.conf file. I have tested it locally and it works when the server ssh into itself but when I try to run the script to ssh into a remote server it logs... (5 Replies)
Discussion started by: mr_dthomas
5 Replies

4. Shell Programming and Scripting

Append Text To Remote Servers File Via SSH

Gentleman & Ladies, Please make me feel like and novice and explain why this is not working? I am attempting to ssh to a remote server via ssh and keys. I want to inject a file on the remote server with text. I am not achieving this. I would like to echo/inject the text on the remote... (1 Reply)
Discussion started by: abacus
1 Replies

5. Solaris

how to login with ssh to remote system with out applying the remote root/usr password

how to login with ssh to remote system with out applying the remote root/user password with rlogin we can ujse .rhosts file but with ssh howits possible plz guide (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

6. Shell Programming and Scripting

Running remote system shell script and c binary file from windows machine using java

Hi, I have an shell script program in a remote linux machine which will do some specific monitoring functionality. Also, have some C executables in that machine. From a windows machine, I want to run the shell script program (If possible using java). I tried with SSH for this. but, in... (1 Reply)
Discussion started by: ram.sj
1 Replies

7. UNIX for Dummies Questions & Answers

Copying text from Windows to AIX - missing text?

Hi All, I'm hoping this is an easy question, but I'm having a weird problem trying to simply copy and paste text from MS Windows (XP) Notepad and then pasting into vi or vim in AIX. When I type "oslevel" I get "5.3.0.0". The problem is that once the text is pasted, there are sections of text... (2 Replies)
Discussion started by: PlainInverted
2 Replies

8. UNIX for Dummies Questions & Answers

Copying from remote SunOS to local Windows 7 computer

Can someone please help me with copying from remote computer to local computer? I have Winscp installed but for some reason i can seem to get into the server using winscp. I am currently logged on to the server, so its not a case of remote host unavailable. I really am not sure if the syntax... (2 Replies)
Discussion started by: dollypee
2 Replies

9. Red Hat

Disable copying secure key's to remote system

Hi, We all know as we can connect remote system through ssh without entering username and password by copy the public key to remote host using ssh-copy-id. But my query is to i want to restrict the user as do not implement this feature.Whenever he is trying to login, he has to enter his/her... (1 Reply)
Discussion started by: mastansaheb
1 Replies

10. IP Networking

Unable to SSH from Windows client to Ubuntu Server

I'm trying to setup a small home network environment as a pet project. These are physical machines nothing virtual. Any help or ideas is greatly appreciated. I can ping between both machines and I have Samba established and can read/write different shares. When I try to SSH from Windows 8.1... (10 Replies)
Discussion started by: lombardi4851
10 Replies
ubuntu-dev-tools(5)						File Formats Manual					       ubuntu-dev-tools(5)

NAME
ubuntu-dev-tools - Configuration for the ubuntu-dev-tools package. DESCRIPTION
The ubuntu-dev-tools package is similar in scope to the devscripts(1) package, providing a collection of scripts which may be of use to Ubuntu and Debian developers or others wishing to build Debian packages. Some of these scripts have options which may be configured on a system-wide and per-user basis. These options are configured in devscripts.conf(5). All variables are described in the script's manpages. Package-wide variables begin with "UBUNTUTOOLS" and are listed below. Every script which reads the configuration files can be forced to ignore them by using the --no-conf command-line option. ENVIRONMENT
All ubuntu-dev-tools configuration variables can be set (and overridden) by setting them in the environment (unlike devscripts). In addition, several scripts use the following environment variables: UBUMAIL Overrides DEBEMAIL and DEBFULLNAME when the target is clearly Ubuntu. Can either contain an e-mail address or Full Name <email@example.org>. DEBEMAIL, DEBFULLNAME As in devscripts(1). PACKAGE-WIDE VARIABLES The currently recognised package-wide variables are: UBUNTUTOOLS_BUILDER This specifies the preferred test-builder, one of pbuilder (default), sbuild, pbuilder-dist. UBUNTUTOOLS_DEBIAN_MIRROR The preferred Debian archive mirror. Should be of the form http://ftp.debian.org/debian (no trailing slash). If not specified, the master will be used. UBUNTUTOOLS_DEBSEC_MIRROR The preferred Debian security archive mirror. Should be of the form http://security.debian.org (no trailing slash). If not speci- fied, the master will be used. UBUNTUTOOLS_UBUNTU_MIRROR The preferred Ubuntu archive mirror. Should be of the form http://archive.ubuntu.com/ubuntu (no trailing slash). If not specified, the master will be used. UBUNTUTOOLS_UBUNTU_PORTS_MIRROR The preferred Ubuntu archive mirror. Should be of the form http://ports.ubuntu.com (no trailing slash). If not specified, the mas- ter will be used. UBUNTUTOOLS_LPINSTANCE The launchpad instance to communicate with. e.g. production (default) or staging. UBUNTUTOOLS_MIRROR_FALLBACK Whether or not to fall-back to the master archive mirror. This is usually the desired behaviour, as mirrors can lag the masters. If on a private network with only a local mirror, you may want to set this to no. One of yes (default) or no. UBUNTUTOOLS_UPDATE_BUILDER Whether or not to update the test-builder before each test build. One of yes or no (default). UBUNTUTOOLS_WORKDIR The directory to use for preparing source packages etc. When unset, defaults to a directory in /tmp/ named after the script. SEE ALSO
devscripts(1), devscripts.conf(5) AUTHORS
This manpage was written by Stefano Rivera <stefanor@ubuntu.com>. ubuntu-dev-tools December 19 2010 ubuntu-dev-tools(5)
All times are GMT -4. The time now is 05:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy