Is there a way to publish a web site from Visual Studio 2008 using SCP or SFTP? I know it is possible to publish to my local filesystem and then perform the transfer with SCP, but I'd like something more seamless (e.g. part of Visual Studio). Does this feature exist? An addin perhaps?
The built in system for publishing pages is a little bit limited.
One thing that I find useful is with WinSCP, there is a featured called "Keep Remote Directory up to Date". What it will do is set a bunch of file system watchers for your local system and if you change something locally, it will auto upload it. Using that and publishing to a local directory makes things easy.
If you have Windows 10 and bash/linux subsystem installed and a Linux/BSD server you can:
Combine ssh and rsync
I prefer to use rsync
through a ssh
pipe, since it won't upload files that werer not modified, it's more efficient.
- from visual studio, publish in a folder, say
I:/www/WebProject
- use this command that updates changes only, and delete files that were deleted/absent from publish folder thanks to
--delete
bash -c "rsync -avH --delete --progress /mnt/i/www/WebProject -e ssh server:/var/www/"
Where I:/www/WebProject
is the local folder where the project was published, and /var/www
the remote directory of the web application.
Preparation (to do once)
You need to work a bit to allow ssh to work without password but with keys.
let's say your bash username is also the same on the server; if not, just use
username@server
name your server:
add
xx.xx.xx.xx server
to the filec:/windows/system32/drivers/etc/hosts
)add your server to hosts from bash with
sudo echo "xx.xx.xx.xx server" >> /etc/hosts
from bash, generate your keys:
ssh --keygen
then [enter] (no passphrase)
- send your public key to the server, in your home folder:
scp ~/.ssh/id_rsa.pub servername:~/
- from your server (
ssh server
then password):
cat id_rsa.pub >> .ssh/authorized_keys && rm id_rsa.pub
Now you can ssh
and scp
without password. IMO this is way better than filezilla or just scp.
© 2022 - 2024 — McMap. All rights reserved.