How do I access remote files using emacs running locally? - networking

Normally, to edit my files, I need to ssh into host sunfire and on that host, I need to ssh into another host xcnc1. My files are on xcnc1 which I can only access through sunfire.
My question is how can I access that xcnc1 files from my local machine?

Use Tramp with ad-hoc proxies. Something like C-x C-f /ssh:user1#sunfire|ssh:user2#xnc1:/path/to/file. If user1 or user2 are the same user as your local one, you could omit them.

Related

How to preserve ownership of file while transferring it to remote server to local server?

I have created a file, say file.sh on my local unix server whose user is say, USER1. Now when I am copying this file from my local server to a remote unix server the ownership is getting changed to USER2.
I have tried many permutations with rsync and scp, but nothing is working.
How can I avoid this ? I want to preserve the ownership of the file as USER1.
Commands used for example:-
scp -pqr /apps/test/scripts/cronbak.sh USER2#remoteserver:/apps/test/scripts
rsync -avz /apps/test/scripts/cronbak.sh USER2#remoteserver:/apps/test/scripts
Thanks.
If you want to preserve the ownership of the file as USER1, you probably have to login as USER1:
scp -pqr /apps/test/scripts/cronbak.sh USER1#remoteserver:/apps/test/scripts
For sure USER1 must be created on remoteserver

how to transfer large directory from server to remote server?

i have SSH access to my source server on digitalocean and ftp access on my azure server then need to move large directory of images from source server to remote server, how can i do it with FTP or mput or similar commands ?
i have only FTP access to remote server.
start with your source server, go to the directory where you have all the files. Start a FTP session to your remote server. After login type prompt
then issue mput *.*.
If you want to get files from target server, then you can use mget
is this what you are looking for?
start FTP connection as follow:
FTP
open destination ftp server
enter username &
password
cd destination folder
lcd source folder path
prompt
mput *.*
all the commands must be the above order.

Editing files on Google Cloud Engine VM

I have recently setup a VM on Google Cloud to develop and host my web site/application. The setup went fine, and I even have gcloud SDK up and running. I also have Apache installed and configured. My question is how do I setup my editing environment (PHP Storm) and upload my files? They seem to have the ports for FTP and SFTP blocked.
FTP uses a clear-text protocol and is thus not recommended. To use SFTP:
Make sure you can ssh to your instance: gcutil --project=<project> ssh <instance>. This does two things: (a) makes sure that port 22 is open on your VM, and (b) propagates your private key to the instance, if it's not already there.
Configure PHP Storm to use the Key pair authentication mechanism using the key ~/.ssh/google_compute_engine to log in to the instance.
That's it.

How do I refer to my local computer for scp'ing when logged into remote?

This must be a really simple question, but I am trying to move a file from a remote server to my local computer, while logged into the remote (via ssh).
All of the guides say to just use
scp name#remote:/path/to/file local/path/to/file
But as far as I can understand, that would be what I would use from my local machine. From the remote machine, I assume that I want to use something like
scp /path/to/file my_local_computer:/local/path/to/file
but (if that's even correct) how do I know what to put in for my_local_computer?
Thanks!
You can automatically figure out where you're logged in from by checking the environment variables SSH_CONNECTION and/or SSH_CLIENT. SSH_CONNECTION for example shows the client address, the outgoing port on the client, the server address and the incoming port on the server. See section ENVIRONMENT in man ssh
So, if you want to copy a file from the server to the client from which you're logged in from, the following (which infers the client ip by taking the first part of SSH_CONNECTION) should work:
scp /path/to/file $(echo $SSH_CONNECTION | cut -f 1 -d ' '):/local/path/to/file
Andreas
You are on the right track! The man page for scp should tell you how to do what you want: http://linux.die.net/man/1/scp
If you are having trouble understanding the man page, then I will attempt to instruct you:
If you want to push a file from your local machine to a remote machine
scp /path/to/local/file testuser#remote-host:/path/to/where/you/want/to/put/file
If you want to pull a file from a remote machine to your local machine
scp testuser#remote-host:/path/to/file/you/want/to/pull /path/on/local/machine/to/place/file
If you are logged into a remote machine and want to push a file to your local machine (assuming you have the ability to scp to the local machine in the first place)
scp /path/on/remote/machine/to/file testuser#local-host:/path/on/local/machine/to/put/file
Now, to determine what your local-host address is, you can check the IP address of your local machine or if your local machine has been provided a DNS entry, you could use it.
I.E., scp ~/myfile testuser#192.168.1.10:/home/testuser/myfile OR scp ~/myfile testuser#my-host:/home/testuser/myfile
For the DNS entry, provided you are on a correctly configured network, you would not need a fully qualified domain. Otherwise, you would need to do something like testuser#my-host.example.com:/home/testuser/myfile
Maybe you can build a solution around this:
who | grep $USER
When run on the remote computer, it should give a hint where you connected form.

Amazon EC2 How Do I Host My Own Content on a Bitnami-Wordpress Instance

I created an instance to host my wordpress blog. I made a keypair, converted it using PuTTY Gen so that it would work with winscp.
My security group that is associated with my instance has:
ICMP Allow All
TCP 0-65535
TCP 22 (SSH)
TCP 80 (HTTP)
TCP 443 (HTTPS)
UDP 0-65535
I am running a Bitnami-Wordpress 3.2.1-0 Ubuntu AMI
My Question is: How do I host a simple file on my instance?
UPDATE: so I was able to login using SFTP by simply filling in my instance Public DNS as my host, and the PuTTY Gen key as the private key, the username I had to use was Bitnami. So now I have access to the server, how or where do I put a file so that it will come out www.mywebsite.com/myfile.file???
I am assuming that I need to SSH into the server using putty, and add it into the WWW directoroy?
What I have tried:
I tried logging in using WinSCP with host name being my instance's Public DNS, and my private key file the converted PuTTY Gen file that was originally the key pair for the instance.
Using SFTP, pressing login it asks me for a user name, entering "user" or "ec2-user" I get an error saying:
"disconnected, no supported authentication methods available (server sent: public key), Server >refused our key. Authentication failed.
Using root for the username, it asks for a passphrase that I created for my keypair using PuTTY Gen, It accepts it, but then I get this error:
"Received too large (1349281121 B) SFTP packet. Max supported packet size is 1024000 B. The error >is typically caused by message printed from startup script (like .profile). The message may start >with ""Plea"". Cannot initialize SFTP protocol. Is the host running a SFTP server?
If in WinSCP I put the username as "user" and the password as "bitnami" (before I press login) (default wordpress password for bitnami AMI) it gives me this error:
Disconnected: No supported authentication methods available (server sent: publickey). Authentication log (see session log for details):Using username: "user". Server refused ourkey. Authentication failed.
I get the same errors using SCP instead of SFTP in WinSCP except when I use SCP and I press login, and I use username "root" it asks me for my passphrase, after entering that I get this error:
Connection has been unexpectedly closed. Server sent command exit status 0. Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended).
Also, if you want to remove wordpress from the URL, you can use the following instructions I posted on my blog (travisnelson.net):
$ sudo chmod 777 /opt/bitnami/apache2/conf/httpd.conf
$ vi /opt/bitnami/apache2/conf/httpd.conf
changed DocumentRoot to be: DocumentRoot “/opt/bitnami/apps/wordpress/htdocs”
$ sudo chmod 544 /opt/bitnami/apache2/conf/httpd.conf
$ sudo apachectl -k restart
Then in WordPress, change the Site address (URL) in General Settings to not have /wordpress.
Hope this helps
If you are already able to connect using SFTP. Now you just need to copy the file. Where you need to copy it depend on what you are trying to do.
BitNami Wordpress AMI has the following directory structure (I only include the relevant directories for this question):
/opt/bitnami
|
|-- apache2/htdocs
|-- apps/wordpress/htdocs
You mentioned that you want to www.mywebsite.com/myfile.file. If you didn't modify the default apache configuration you will need to copy file in /opt/bitnami/apache2/htdocs (this is the DocumentRoot for the BitNami WordPress AMI.
If you want that file to be accessed from www.mywebsite.com/wordpress/myfile.file, then you need to copy it in /opt/bitnami/apps/wordpress/htdocs.
If what you are trying to do is to manually install a theme or plugin you can follow the WordPress documentation taking into account that the wordpress installation directory is /opt/bitnami/apps/wordpress/htdocs.
Also, you can find below some links to the BitNami Wiki explaining how to connect to the AMIs. I just include them as a reference for other users that find the same connection issues.
Further reading:
How to connect to your amazon instance
How to upload files from Windows
I had a similar problem recently. Having setup Bitnami Wordpress on AmazonAWS I was unable to modify, add, or remove themes from within the Wordpress admin interface even though all of my permissions were setup appropriately according to Wordpress recommended settings. However, I did not want to have to resort to turning FTP access on.
I was able to resolve the issue by:
Setting the file access method for Bitnami Wordpress to 'direct'.
Changing all users to Apache Bitnami.
Adding Bitnami to Apache group and Apache to Bitnami group.

Resources