How to change where Remote - SSH puts files - visual-studio-code

I have restrictions on the home directory of my remote machine, is there a way to change where Vscode Remote - SSH puts it's collateral files (~/.vscode, ~/.vscode-server, ...)?
I've looked through all the settings and haven't found anything that looks right
I need the ~/.vscode to be located somewhere besides home folder

I found the active feature request https://github.com/microsoft/vscode-remote-release/issues/472
To get around this for now you can link ~/.vscode-server to another folder/drive
ln -s /path/to/big/disk/.vscode-server ~/.vscode-server

Related

Problems upolading files from local to server using scp

I'm having problems in uploading some folders from the local machine to a server.
When I run the command
scp -r -i pathtokey.txt pathtomyfiles pathtotheserver
For some folders the transfer doesn't succed. I noticed that this happens for the folders where I have R projects. It transfers just usually hidden files named as "source-pane.pper" "chunks.json", but nothing else.
For other folders, where I don't have any of that, the transfer goes fine, meaning that the command I'm using is ok.
Any suggestion of what is happening here and how to solve?
Just to give you all the information, my local machine has windows system
Thanks a lot,
Francesca
I'm unsure why this is failing unfortunately. However an alternative may be to look at using rsync:
rsync <options> <source> <destination>
rsync -azv source_dir/ username#server:~/path/to/folder
I've not tried this while specifying an ssh key explicitly but the answer below explains how to do so. Alternatively you can just type in the password manually if you know it.
https://unix.stackexchange.com/questions/127352/specify-identity-file-id-rsa-with-rsync

I've already setup the ssh key, but VSCode keeps asking for password

I'm using a macbook(MacOS) to connect to a remote Ubuntu server.
I copied the public ssh key to the server using ssh-copy-id and checked that the ssh key works on the terminal. When I do ssh username#x.x.x.x, connection is made without asking for password).
However, when I try to connect to the server through Visual Studio Code, VSCode keeps asking for password. Is there a way to fix this?
Thanks in advance!
It was a problem with the config file.
The VSCode needs the "absolute" path.
In case of MacOS, ssh-copy-id seems to only copy the absolute path relative to the user.
In other words, it omits "/Users/username" before "/.ssh".
Adding "/Users/username" in the IdentityFile attribute in .ssh/config solved the problem.
Check if this microsoft/vscode-remote-release issue 2518 applies:
You should be able to get out of this state by deleting the file (on the remote server side, as sudo root) in the log, /home/#####/.vscode-server/bin/78a4c91400152c0f27ba4d363eb56d2835f9903a/vscode-remote-lock.#####.78a4c91400152c0f27ba4d363eb56d2835f9903a (with unlink) or running the command "Kill VS Code Server on Host..."
If it happens again, you might try setting remote.SSH.useFlock.
The exact command to run in the command palette (View->Command Palette) is:
Remote-SSH: Kill VS Code Server on Host...
Also:
In my case, deleting entire ~/.vscode-server directory after connecting to the container through ssh using terminal worked.
(Deleting only ~/.vscode-server/bin did not work.)
The OP sukrama confirms in the comments having solved the issue
It was a problem with ssh key path in config file.
Here's a quick and handy fix: You do not have to delete the entire .vscode-server folder each time! The problem seems to be a file named 'vscode-remote-lock...'. It can be located inside a folder in ~/.vscode-server/bin/ . That file gets created at each ssh login through vscode. Run the following script on the remote host. It deletes that file whenever it is created:
while true
do
if ls /home/<your-username>/.vscode-server/bin/*/vscode-remote-lock.<your-username>.* 1> /dev/null 2>&1; then
find /home/<your-username>/.vscode-server/bin/*/ -name vscode-remote-lock.<your-username>.* -delete
echo "Killed the troublemaker! ^_^"
fi
done
The file names and the folder names may differ from machine to machine. So find the names on your machine and paste them in the script. Then run the script and you're good to go.
VSCode in my Windows machine was asking for password even with my key correctly configured (it works from the terminal).
My problem was that VSCode was choosing a wrong user. I was using a host configured in my ssh config file, and VSCode was setting the user as DOMAIN\user instead of user. I solved it configuring the correct user in my .ssh/config file:
Host dados
HostName vrt1234
User xxxxx
In case you're having this problem in Windows, keep in mind that the public/private keys that you might use to connect to a remote machine from WSL aren't the same ones that VS Code will use to connect from Windows. You need to create a separate public/private key pair for Windows, and export that private key to the remote server too.
From VS Code remote debug tips and tricks:
In a Powershell window, create a public/private key pair just as you would in a Linux terminal:
ssh-keygen -t rsa -b 4096
Then export it to the remote server:
export USER_AT_HOST="your-user-name-on-host#hostname"
export PUBKEYPATH="$HOME/.ssh/id_rsa.pub"
ssh $USER_AT_HOST "powershell New-Item -Force -ItemType Directory -Path \"\$HOME\\.ssh\"; Add-Content -Force -Path \"\$HOME\\.ssh\\authorized_keys\" -Value '$(tr -d '\n\r' < "$PUBKEYPATH")'"
Make sure you can connect via passwordless SSH via PowerShell.
Finally, in VS Code. press Ctrl+Shift+P to open the command palette and select "Remote-SSH: Open SSH Configuration File..." and edit the config file like so:
Host [convenient name]
HostName [hostname]
User [username]
IdentityFile C:\Users\[username]\.ssh\id_rsa*
Then when you run "Remote-SSH: Connect to Host..." in VS Code and choose the host above, it should connect without prompting for a password.
I had to use UseKeychain yes in my ~/.ssh/config file.
The config file looks like this:
Host server.tld
HostName server.tld
User user
UseKeychain yes
IdentityFile ~/.ssh/key
You have to enter ssh-add -K ~/.ssh/key to add your passphrase to KeyChain first.
Not enough rep to comment, but if you followed the steps from this Stack Overflow post and are still running into issues, your VSCode Remote-SSH config file path may not be set.
Make sure that the setting remote.SSH.configFile is set to ~/.ssh/config.
You could also type Ctrl + Shift + P to open the Command Palette.
Inside the Command Palette type,
Remote-SSH: Kill VS Code Server on Host...
You will be required to type in your server password for it to work.
In case this helps someone, i had a similar issue where VSC was asking for a password (instead of a passphrase).
I noticed that my key was on a network drive and it looks like VSC cannot read it there.
I moved it to a local file (C:) and it worked.
For me it was that my public auth ssh was not working and my home directory permissions were the problem. I had to remove group and other write permissions to my home directory and then everything worked:
chmod go-w ~/
(macos+vscode)
Only this worked for me:
https://www.backarapper.com/add-ssh-keys-to-ssh-agent-on-startup-in-macos/
ie: adding the key by ssh-add and then writing this in the ~/.ssh/config file:
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/[your-secure-ssh-key-name]

'ssh' is not recognized as an internal or external command

I have been trying to deploy my app into the Fortrabbit servers using the command line. I'm using windows. Here is what I tried :
C:\projects\riwaya>git remote add fort git#git2.eu1.frbit.com:riwaya.git
C:\projects\riwaya>git remote fort
C:\projects\riwaya>ssh u-riwaya#ssh2.eu1.frbit.com
'ssh' is not recognized as an internal or external command, operable program or batch file.
I have watched This Laracast Video and did the same as Jeffrey but it doesn't work ...
Can somebody help ?
Actually you have 2 problems here: First is that you don't have ssh installed, second is that you don't know how to deploy
Install SSH
It seems that ssh is not installed on your computer.
You can install openssh from here : http://openssh.en.softonic.com/download
Generate your key
Than you will have to geneate your ssh-key. There's a good tutorial about this here:
https://help.github.com/articles/generating-ssh-keys#platform-windows
Deploy
To deploy, you just have to push your code over git. Something like this:
git push fort master
If you get permission denied, be sure that you have put your public_key in the dashboard in the git tab.
SSH
The ssh command gives you access to your remote node. You should have received a password by email and now that you have ssh installed, you should be asked for a password when trying to connect. just input that password. If you want to use your private ssh key to connect to your server rather then typing that password, you can follow this : http://fortrabbit.com/docs/how-to/ssh-sftp/enable-public-key-authentication
For Windows, first install the git base from here: https://git-scm.com/downloads
Next, set the environment variable:
Press Windows+R and type sysdm.cpl
Select advance -> Environment variable
Select path-> edit the path and paste the below line:
C:\Program Files\Git\git-bash.exe
To test it, open the command window: press Windows+R, type cmd and then type ssh.
First of all Go to browser and install openssh here: https://github.com/PowerShell/Win32-OpenSSH/releases
Next step, extract rar file into folder and then copy and paste it in your drive.
after that run command: ssh it should work.
Next step is right click on shh in openssh folder and go to properties. Copy the path
and paste it in system variables in edit environment variables.
It will work fine.
TLDR, add this to settings.json
"terminal.integrated.env.windows":
{
"PATH": "C:/Windows/System32/OpenSSH",
},
Just found a case when the integrated terminal hasn't recognized 'ssh' as command, but you tried 'ssh' that was working on external terminals like CMD, git-bash.
That means you didn't add PATH variable to your integrated terminal.
If anyone looking for solution even now, here is how I did it for my Windows 10 machine.
Start > type 'Manage Optional Features'
Add Feature [+]
Look for OpenSSH client & select & install
After successful installation, open (close if already opened) powershell or command prompt and run ssh!

Installing Meteor - Couldn't write the launcher script

I am front-end developer attempting to crossover into the world of web app development. I've come a long way in learning Javascript, and now I'm looking to toy around with frameworks.
I still have a bit to learn about using the OSX terminal, but I was hoping somebody could help me with this first stumble I'm having....
I try to install meteor using:
$ curl https://install.meteor.com | /bin/sh
Then I get the following:
Meteor 0.6.4 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.
cp: /usr/local/bin/meteor: No such file or directory
Couldn't write the launcher script. Please either:
(1) Run the following as root:
cp ~/.meteor/tools/latest/launch-meteor /usr/bin/meteor
(2) Add ~/.meteor to your path, or
(3) Rerun this command to try again.
Then to get started, take a look at 'meteor --help' or see the docs at
docs.meteor.com.
If it's still helpful to anyone, going into /usr/local/bin, running "sudo rm meteor" then running the install gets it to work for me
Yeah try one of the three suggestions or:
sudo curl https://install.meteor.com | /bin/sh
I had the same problem heres how I fixed it!
Delete all meteor folders
In finder (cmd +shft+g)
type in "~/.meteor"
on the top of the finder window where is has the folder.meteor click and drag folder to trash
In finder (cmd +shft+g) type in "/usr/bin/meteor" then drag the meteor folder to trash
3.In /usr/ create a new folder "local" (password required) and inside "local" create a folder "bin"
Go back to terminal a run curl https://install.meteor.com | /bin/sh

Unable to run PostgreSQL as Windows service

I had this in my Windows services:
C:/Program Files/PostgreSQL/8.4/bin/pg_ctl.exe runservice -N "postgresql-8.4" -D "D:/PostgreSQL/8.4/data" -w
It never finishes executing. But if I did this on the dos shell:
C:/Program Files/PostgreSQL/8.4/bin/pg_ctl.exe start -N "postgresql-8.4" -D "D:/PostgreSQL/8.4/data" -w
Notice that I only changed the "runservice" to "start" and it works just fine.
Any idea?
The command runservice can only be executed by the service manager
in order to fix my localhost windows 7 to start postgres as a service
i used the following command to start the data
pg_ctl -D "C:\Program Files\PostgreSQL\9.1\data" start
Then checked the status for errors
pg_ctl -D "C:\Program Files\PostgreSQL\9.1\data" status
if you get error 1063 , its more than likely permissions, i executed the following command
cacls "C:\Program Files\PostgreSQL\9.1\data" /E /T /C /G postgres:F
then reran the start/status, it showed everything fine, but still service manager would not start the service
So, in Services->postgresql->options->logon i set the log on as the Local system account instead of the postgres user, and voila it worked
this happened to me because i set my data directory to be somewhere the postgres windows user account didn't have access to.
I had this problem in Windows after a system crash. Running the first command showed invalid data in C:\Program Files\PostgreSQL\9.1\data\postmaster.pid. Deleting that file did the trick. Reference.
I faced the same issue after moving manually the database data files (PG_DATA directory) without recreating all the necessary permissions.
Here is how I solved my issue:
1. Check permissions on old PG_DATA directory:
cacls "c:\path\to\old\pgdata\dir"
2. Check permissions on new PG_DATA directory:
cacls "d:\path\to\NEW\pgdata\dir"
3. Compare outputs from 1. and 2.
Find the differences between users and/or permissions then synchronize them.
Nota: I found it easier to use explorer for the synchronization step rather than using cacls directly from the command line.
If you changed pg_hba.conf , maybe you missed somewhere in file. For example there must be CIDR after IP in that file. It must be like 192.168.1.100/32
If you forgot to put 32, then server doesnt restart.
Investigation of startup logs could be a clue. For the case problem is in the pg_hba.conf you could see something like this:
2018-11-13 00:39:34.841 PST [8284] FATAL: could not load pg_hba.conf
2018-11-13 00:39:34.842 PST [8284] LOG: database system is shut down
You need to check your logfiles and the windows eventlog for some hint of what the problem is. If there is nothing at all there, you need to break out something like Process Monitor and get a stacktrace of where it's hung.
I have had this issue in the past, and it was that the installer did not set up the permissions correctly for the user that the service was to run as.
I've also ran into this problem with postgresql throwing and error after trying to initialize the database cluster. After analyzing the log files and running command line scripts for 4 hours I've got the solution to anyone running into this problem for Windows Versions.
This is not a detailed description as to why its happening. I've installed odoo 10, 11, 12 and 13 numerous times on countless client servers and windows systems and this is the first time I've ever ran into this problem. I cant say if its because I have MS VS Enterprise installed and Android Studio on this machine or what. But Below is the easy answer on how to fix it and initialize the cluster and create the database files in the data folder.
Open the data folder for postgresql. - For Odoo installs it will normally be "C:\Program Files (x86)\Odoo 13.0\PostgreSQL" Unless you chose another location when installing.
Remove any or all files from this folder - If not you will get an error when running initdb.exe
Right click the data folder and open up the properties for it. Click on the Security tab and then click the advanced button on the bottom.
You need to change the owner of this folder to openpgsvc. Click Change and type in openpgsvc and click ok. Once done click the check box below saying that you want this change to affect containers with this container as well.
Then on the Permissions tab click the add button on the bottom. You need to add openpgsvc as a user and give this user full rights. Click apply and and ok to close out of all the folder properties.
Now you need to open cmd.exe - Once open we are going to call initdb.exe and pass some values to it as well.
First run chdir and change the working directory to the location of initdb.exe. For me, running odoo 13 on a windows 10 machine the location is this..
"C:\Program Files (x86)\Odoo 13.0\PostgreSQL\bin"
There is one variable that need to be passed as well to make this work here is the list. NEEDS TO BE INCLUDED IN THE CALL TO initdb.exe
Postgres Data Dir: "C:\Program Files (x86)\Odoo 13.0\PostgreSQL\data"
The End Result with the parameter would look like this for my installation:
"C:\Program Files (x86)\Odoo 13.0\PostgreSQL\bin\initdb.exe" -D "C:\Program Files (x86)\Odoo 13.0\PostgreSQL\data"
Hit Enter and let it rip. The output of this command should look like this below.
Cmd.exe running initdb.exe script
Make sure there is no buggy empty file Program at C:\ like C:\Program
In this case, explorer will warn whenever you log on into Windows.
File Name Warning
-----------------
There is a file or folder on your computer called "C:\Program" which
could cause certain applications to not function correctly. Renaming it
to "C:\Program1" would solve this problem. Would you like to rename
it now?
Installing PostgreSQL 10 On Windows 7 (yes the clock is ticking...). I first tried the latest version 11 which completely failed to install... not a good sign for Windows users. Anyway.
Quick answer: Change the account in the Windows Services panel from Network to Local.
Details of my case
During installation I created/selected a data folder in the user profile folder, because obviously the folder suggested by default, within the program folder, wouldn't work, and if it worked it would be a very idea to put data here (I don't know whether it's usual to do that on Unix/Linux, but for Windows it's it's not allowed for a long time).
At the end (when populating the data cluster) I received an error:
Failed to load SQL Modules into database Cluster
but the installation was able to complete. I found two pages about previous error, here and here, but they didn't seem relevant to my case, so I just started pgAdmin and, on the left "browser", saw the server wasn't active.
I tried to start it from here (had to type the main password), but it went inactive immediately again. So I tried to use the Windows services panel to start "postgresql-x64-10", no joy. I copied the command from this panel and pasted it into a Windows console (cmd.exe) where I finally received this
error 1063.
Searching I found this related question, and was convinced the problem was about permissions.
Solution working for my case
In the services panel I changed the account used to start the service from Network Service to Local System as suggested in a comment by #AlexanderRios.
sc create "postgresql-9.2" binPath= "\"C:/Program Files (x86)/PostgreSQL/9.2/bin/pg_ctl.exe\" runservice -N \"postgresql-9.2\" -D \"C:/Program Files (x86)/PostgreSQL/9.2/data\" -w" DisplayName= "postgresql-9.2" start= auto
Try this on CMD run as Administrator
(Add your parameters depend on your version)
Stop all postgres processes
Go to the postgres data folder (C:\Program Files\PostgreSQL\9.6\data)
Delete the postmaster.opts and postmaster.pid files
From the control panel, in administrative
tools and the services console start the postgres service
open pgAdmin III and then in right pane find server then just right click and connect, enter the password. after connected go to the browser and refresh ODOO. Problem solved.
See image to get better understanding