I have a desktop in the office that I often need to access from home and use scp to copy files. Currently I am doing it like this
scp username#x.x.x.x ...
I want a mechanism that I dont have to type the IP address each time I want to scp something. I was trying to do it by creating an alias, but it doesn't seem to work.
Can I give my desktop machine a name so that instead of typing the ip address I can use the name of the machine instead ?
One way to deal with this is to create an entry in your ssh configuration. This can be done on a system wide basis or, if you don't have root access on this box, just for your user.
The per user configuration file is ~/.ssh/config and uses the following format
host my_desktop
hostname 11.22.33.44
This method is also nice because you can specify other options like the user name. To find out more about the options available try man ssh_config.
You should have a HOSTS file on your system that's designed to do exactly that. On my Linux system, it's located at /etc/hosts. If you add a line that looks like this:
11.22.33.44 my_desktop
then all accesses to the name my_desktop will be mapped to the IP address listed. This change only affects the machine whose HOSTS file was modified, though. If you want to make it so that anybody can access an IP using a specific name, then you're looking at something a little more difficult (this is the general problem that DNS servers were designed to resolve).
Use a environment variable to hold your IP and username - then use the variable in the scp command.
user#crunchbang:~$ export mypc='myuser#x.x.x.x'
user#crunchbang:~$ scp $mypc: ......
Related
I normally use Linux and everything goes very well. :-)
But I have a machine which runs with Windows 7. :-\
When I try to connect to a server using Git Bash I receive following message:
The authenticity of host '144.76.35.106 (144.76.35.106)' can't be established.
ECDSA key fingerprint is 50:50:10:f7:40:50:b8:3a:20:c5:20:20:00:a0:d8:70.
Are you sure you want to continue connecting (yes/no)?
Normally I should only type yes and hit enter. But we are talking about Windows... ;-)
The problem is that in this special case the folder ~/.ssh is not writeable and I'm unable to change rights. (Why is that so is related to the security philosophy of the company. Unfortunately I have no influence here).
So I would like to know if there's any chance to change this: So when I type yes and hit enter the file known_hosts is saved in another place and most important, that the file is read next time when I access the server once again.
In other words: Where can I configure that Git look for known_hosts in another place than ~/.ssh using Windows?
Many thanks in advance!!!
The problem is that in this special case the folder ~/.ssh is not writeable and I'm unable to change rights.
Here is simply the value referenced by the environment variable HOME.
Check its value with echo $HOME in your bash session.
HOME should be set by default to %USERPROFILE%, but you can set it to any other folder of your choice, where you know you have the right to write.
I already written a script to delete files on pc's. I have a text file full of IPs, how do I edit the script to access all the pc's? all the computers has the same username and password and can I just add the commands above my script?
Thanks
Something along the lines of this might do what you want?
for machine in $(cat machines.txt);
do
scp myscript $mymachine
ssh $machine myscript
done
It is likely you will need to administer these machines in future, so I suggest you look into configuration management tools like chef or puppet
There is a Mac on our network (let's call it MACHINE) that is configured to do LDAP authentication. There is no local user named USER on this Mac, but there is a user named USER known to the LDAP server.
When I execute this command from my Mac:
ssh USER#MACHINE echo \$PATH
where is that path being loaded from?
(notice the path I get that way is quite different from if I do the ssh, open a remote session, and then type echo $PATH)
There are a lot of places that the path isn't being loaded from (I know this because they specify paths that don't appear in the actual \$PATH):
/etc/paths
/etc/paths.d
/etc/bashrc
Thanks,
Chris
There is usually a template user account provided by a Unix'y system, and I am pretty sure it will include a path in it. Usually that would be etc/skel.
On the Mac it is:
/System/Library/User\ Template/
I've got a Lacie Network Space 2 where they have disabled the SSH access and I'd like to write a script where I transfer files from my computer to the NS2 using scp.
The only problem I have is that I can't (from what I know) generate a public key without first connecting via SSH.
So my question is: Is it possible to generate a key without having access to SSH, for use with scp? Or some other clever way to transfer files to my NS2 (FW 2.2.4) using a script.
I might add that I'm currently mounting the disk and using cp, but I'd like something better.
Thanks in advance!
What exactly do you want? If you want to scp to the NS2, you'll have to generate the keys on the source machines and append it to authorized_keys on the target. Since you can already mount & use cp, you should be able to do that.
Note that since scp works over ssh, if they've disabled ssh this won't work. OTOH, if they've only disabled password based ssh, or set /bin/false as your shell, this might work.
I have concluded that if you want to gain access to ssh keys on your NS2 with a newer FW you have to remove the disk from its casing and connect it to a computer, as they explain in this link
Enabling SSH on NS2
I thank you both for your answers, but I guess I'll have to do it the hard way.
The github instructions say to setup your SSH keys in ~/.ssh using the windows git bash program.
I have in the past used Putty to manage ssh keys.
What is the difference between the 2 setups?
This is for my own git server.
I know this is a pretty old question, but here's the answer:
Basically, PuTTY stores all its sessions in the Windows registry, rather than in a config file in a home folder, whereas the default git+ssh setup uses openSSH and it's style of key configuration (files that are typically stored in ~/.ssh, i.e., /home/<username>/.ssh).
In Windows, if you'd rather use PuTTY than openSSH, set an environment variable named GIT_SSH to C:\your\putty\folder\plink.exe. Then, you can reference any saved session in PuTTY by using a remote url of the form ssh://<session name>/<repository path>. This allows you to, for example, specify particular keys with each session, similarly to how you could use ~/.ssh/config to specify a particular key with the IdentityFile option.
Git uses an SSH program to deal with SSH accesses, basically the default one depending on your system (look at the GIT_SSH environment variable). So it's just to ease the configuration that they say to setup SSH keys in ~/.ssh. If you want to put SSH keys in another directory, just tell it by using ssh-add /path/to/your/key.