transfer file from server to home computer - server

I have a text file on the server(linux) at work and now I am at home. I am a putty user. to connect to the server from home I have to connect to another server (which means I can connect to the server at work, indirectly from home) so I can't use scp command or winscp to transfer or copy my file to my computer at home. does anybody know that how I can transfer or copy my file from the server at work to my home computer(windows system)? thanks.

Since it's a text file, putty's capture feature should work for you. In putty, the capture feature is in Category Session → Logging. Just specify the local filename that you want to save the text file to on your Windows machine, then use Linux's cat command to cat the file on the remote Linux host. With capture enabled in putty, it should save the output of the cat command (i.e. the contents of the text file) to a file locally on your Windows machine.

Related

How do I get remote access with PowerShell?

I want to connect to a specific set of laptops on our domain remotely. I need to have it log to the C drive, and search out a specific folder, then report back on a specific file contained in the folder.
I have found scripts that have shown me how to locate and show if the path exists, along with a specific file name at the end of the path. I created a test file on my laptop and the script worked flawlessly.
However, I need it to reach out over our domain, log into the target laptop, locate the file and contents then create a report on the findings. This will need to be done over VPN to the devices on our network.
My main issue at this point is finding the commands to invoke PowerShell to log onto the remote computers.
A rough overview on how to remote execute commands with PowerShell.
Enable PSRemoting with Enable-PSRemoting MS docs
Establish a remote connection with Enter-PSSession -ComputerName testserver123.global.local
This opens a prompt of the remote server where you can run commands. Your PS prompt will get a prefix indicating the remote server.
A useful link is here from 4sysops

Getting the list of files in website's folder through terminal

I've configured Apache2 for a specific directory, so that it lists all its contents over HTTP (I put +Indexesin config).
I was wondering if it is possible to list the contents of that folder from my terminal? So basically instead of opening up a browser and visiting that directory over HTTP, is it possible to do it just from terminal?
Some ideas:
use ssh to connect to the webserver: ssh user#host ls /path/to/dir; requires ssh access obviously
add a cgi script to generate the output you want in a format (test/plain) you want

SFTP inline put without interaction

I am trying to automate an application deployment as part of this I need to upload a file to a server. I have created a minimal user and configured chroot for the SFTP server but I can't work out how to upload a file non interactive.
At present I am doing scp myfile buildUser#myserver.com:newBuilds/
I tried sftp buildUser#myserver.com myfile (newBuilds is the chroot dir) but this didn't upload anything but it did connect.
The reason for favouring this aproach and NOT using scp is that its a lot more difficult to restrict scp access (from the information I have learned).
If you are using OpenSSH server, chrooting works for both SCP and SFTP.
For instructions see:
https://www.techrepublic.com/article/chroot-users-with-openssh-an-easier-way-to-confine-users-to-their-home-directories/
So I believe your question is irrelevant.
Anyway, sftp (assuming OpenSSH) is not really designed for command-line-only upload. You typically use -b switch to specify batch file with put command.
sftp buildUser#myserver.com -b batchfile
With batchfile containing:
put /local/path /remote/path
If you really need command-line-only upload, see:
Single line sftp from terminal or
Using sftp like scp
So basically, you can use various forms of input redirection like:
sftp buildUser#myserver.com <<< 'put /local/path /remote/path'
Or simply use scp, instead of sftp. Most servers support both. And actually OpenSSH scp supports SFTP protocol since 8.7.
Since OpenSSH 9.0 is even uses SFTP by default. In 8.7 through 8.9, the SFTP has to be selected via -s parameter. See my answer to already mentioned Single line sftp from terminal.
You can pass inline commands to SFTP like this:
sftp -o PasswordAuthentication=no user#host <<END
lcd /path/to/local/dir
cd /path/to/remote/dir
put file
END
I resolved this issue by approaching it from a different side. I tried configuring chroot for sftp but could not get this to work. My solution was to use rssh and only allow scp. This works for me because the user I am trying to restrict is known and authenticated user.

copy file to remote desktop drive

I want to copy a file from my local C:\filename.png to the remote computer to which I am connected via remote desktop's C:\ drive.
Is it possible to copy using powershell or anyother terminal command?
I am using windows 7 (local PC) --- Remote Desktop (Windows Server 2003)
If your host's c: drive is injected into a terminal services session, it just gets a new drive letter in the remote session.
On my network, my host machine's drives are injected into a VM and C: becomes M:.
So in that case, in the remote session:
copy c:\file.png m:\png
BUt perhaps a beter way - from your host:
Copy \\remote\c$\file.png c:\file.png
My remote session usually names the local resource tsclient, such that I can browse my local C drive with this PS command:
Set-Location \\tsclient\C
then I can do anything I would normally do on the local file system, e.g. copying:
copy \\tsclient\C\file.txt C:\file.txt
You can share a folder on your server and map it as network drive on the client computer. Then you can use the copy command.
At the server side you kann check and deplace the files manually or with a program.
if both are Windows 7 ;
Just copy and paste done in ordinary window
If both machines run the same OS, then it can be achieved
If you are using mstc program then
Go to Remote Desktop Connection -> Options -> Local Resources -> check the drivers option and connect to the remote PC. Then you can perform copy paste like usual

In Netbeans, can you do SSH connection for PHP Projects?

Netbean is great and I use it with FTP remote connection all the time. However, one of my client currently only have a SSH connection. Is there anyway to connect to it and up/down files?
Like it was mentioned, SFTP is supported in Netbeans by default.
So select "remote connection" in your project's run configuration and use your SSH connection information (host, login and pass). You don't have to provide any private key file.
I've had luck using sshfs (ssh file system) on ubuntu. I create created a mount folder in my home folder and run the following
$ sshfs domain\\user#server:/path/to/remote/folder ~/mount/local-mount-point
From there I start a new (or existing) project in Netbeans at that local folder ~/mount/local-mount-point
For a nicer set up, do a key exchange between your local box and the server (ssh-copy-id) for password-less ssh connections. Then, put the above command line in your .bashrc file.
I do the same as Richard.
In general is easier just to mount the remote filesystem and use netbeans in the mounted directory.
I just do the following :
sudo sshfs -o allow_other root#www.khosmos.com:/var/www/html /mnt/droplet/